更新:哇,你們都是對的!
至於原因,我還不知道,我需要: 「從BeautifulSoup進口BeautifulSoup」 ,並添加行:Python /解析:BeautifulSoup錯誤「module obj is callable」with Mechanize
response = br.submit()
print type(response) #new line
raw = br.response().read()#new line
print type(raw)#new line
print type(br.response().read())#new line
cooked = (br.response().read())#new line
soup = BeautifulSoup(cooked)
/更新
嗯,BeautifulSoup和我是不承認的結果br.response()。read()。 我已經導入BeautifulSoup ...
#snippet:
# Select the first (index zero) form
br.select_form(nr=0)
br.form.set_all_readonly(False)
br['__EVENTTARGET'] = list_of_dates[0]
br['__EVENTARGUMENT'] = 'calMain'
br['__VIEWSTATE'] = viewstate
br['__EVENTVALIDATION'] = eventvalidation
response = br.submit()
print br.response().read() #*#this prints the html I'm expecting*
soup = BeautifulSoup(br.response().read()) #*#but this throws
#TypeError: 'module' object is not callable.
#Yet if I call soup = BeautifulSoup("http://page.com"), it's cool.*
selecttable = soup.find('table',{'id':"tblItems"})
#/snippet
...等等
所以我神交我有錯的那種「對象」,而人,什麼樣的「對象」的呢BeautifulSoup想要,你認爲?
乾杯和感謝!
你用什麼導入語句導入美麗的湯? – Trevor
相關:http://stackoverflow.com/questions/3368231/beautifulsouphtml-not-working-saying-cant-call-module – jfs
您的更新腳本再次做br.response.read()兩次。你需要調用'BeautifulSoup(raw)'。你應該只調用一次response.read。另外,你可能不應該調用模塊對象,而是應該在響應對象上調用它。 –