0
我想寫一個蜘蛛抓取一個html。我使用requests
和beautifulsoup
,但我發現美麗的臉不能分析整個頁面。相反,Beautifulsoup只是解析它的一半。 這裏是我的代碼:Beaultifusoup無法解析所有的html
import requests
from bs4 import BeautifulSoup as bs
urls = ['http://www.bishefuwu.com/developer/transmit','http://www.bishefuwu.com/developer/transmit/index/p/2.html']
html = requests.get(urls[0]).content
soup = bs(html,'lxml')
table = soup.find('tbody')
trs = table.find_all('tr')
for tr in trs:
r = tr.find_all('td')[:3]
for i in map(lambda x:x.get_text(),r):
print i
,這是the origin page,裏面有行「13107」, 但我的蜘蛛只是有它的一半,我排停在「13192」。 爲了測試,我手動保存requests
所要求的原始HTML,我發現一切都很好。這個錯誤在Beautifulsoup上。 我該如何解決它? 謝謝
非常感謝! – ucag