簡體   English   中英

在網站上從網站抓取表格

[英]Web scraping the table from the website

嗨,我正在嘗試從https://html5test.com/上獲取並解析所有表數據。 因此,我編寫了以下代碼。但是它沒有顯示任何數據。 我查看了問題答案,但無法找出問題所在。

from BeautifulSoup import BeautifulSoup
from urllib2 import urlopen
import re


url='https://html5test.com/'
data=urlopen(url)

parse=BeautifulSoup(data).findAll('div', attrs={'class': 'resultsTable detailsTable'})

查看源代碼(在Chrome中查看源代碼: https//html5test.com/ ),我實際上沒有找到'resultsTable`類。 看起來這是使用JavaScript動態生成的。 您需要一個可呈現JavaScript的刮板,例如Scrapy with Splash(參見https://blog.scrapinghub.com/2015/03/02/handling-javascript-in-scrapy-with-splash/ )。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM