我想用Python解析一個html文件,並且我使用的模塊是beautifulsoup。beautifulsoup findAll find_all
我用它之後,一些奇怪happened.It據說功能「find_all」是
一樣「的findAll」,但我已經試過他們兩個。但它是不同的。
誰能告訴我不同嗎?
import urllib, urllib2, cookielib
from BeautifulSoup import *
site = "http://share.dmhy.org/topics/list?keyword=TARI+TARI+team_id%3A407"
rqstr = urllib2.Request(site)
rq = urllib2.urlopen(rqstr)
fchData = rq.read()
soup = BeautifulSoup(fchData)
t = soup.findAll('tr')
print t
您使用哪個beautifulsoup的版本?如果你應該使用BS4,那麼導入應該是'from bs4 import BeautifulSoup'。見http://www.crummy.com/software/BeautifulSoup/bs4/doc/#porting-code-to-bs4 – marchelbling
有什麼區別?我的意思是,你說你使用了兩種,你看到了不同。你可以發佈一些顯示不同行爲的輸出嗎?或者你問爲什麼有兩種方法可以做同樣的事情?在這種情況下,Martijn Pieters是正確的。 – Bakuriu
find_all:找不到模塊 findAll:它找到了html代碼的幾個部分。 – Oberon