网页(关于足球和评分):
http://www.fantagazzetta.com/voti-serie-a
我尝试了什么:
如何从html页面中提取文本?
我试着在他的回答中使用用户JRodDynamite提供的代码(最后只是打印res并且不做for for thing)。 所以我需要编辑这部分代码(我猜):
res = soup.findAll("article", {"class": "listingItem"})为了打印每个表的内容,我认为答案是:
res = soup.findAll("table", {"class": "table"})但它不打印任何东西。 所以我需要你的帮助:我想从该网页收集数据(玩家的名字和评级),但我坚持这一点。 谢谢
Web page (about football and ratings) :
http://www.fantagazzetta.com/voti-serie-a
What i tried:
How to extract text from html page?
I tried using the code provided by the user JRodDynamite in his answer (and in the end just printing res and not doing the for thing). So i needed to edit just this part of the code (i guess):
res = soup.findAll("article", {"class": "listingItem"})To print each table's content i thought the answer was:
res = soup.findAll("table", {"class": "table"})But it's not printing anything. So I need your help: i would like to collect the data from that web page (player's name and rating) but i'm stuck on this point. Thanks
最满意答案
BeautifulSoup,请求等不执行Javascript,因此通过JS传递或呈现的任何数据都不可用。
对于JavaScript呈现的页面,您可以尝试使用dryscrape如下所示:
import dryscrape from bs4 import BeautifulSoup sess = dryscrape.Session() sess.visit('http://www.fantagazzetta.com/voti-serie-a#') s = BeautifulSoup(sess.body()) for a in s.find_all('table', {'class': 'table'}): print(a.text)Dryscrape安装:
sudo pip install dryscrapeBeautifulSoup, requests, etc. does not execute Javascript, so any data delivered or rendered via JS will not be available to you.
For JavaScript rendered pages you can try with dryscrape like so:
import dryscrape from bs4 import BeautifulSoup sess = dryscrape.Session() sess.visit('http://www.fantagazzetta.com/voti-serie-a#') s = BeautifulSoup(sess.body()) for a in s.find_all('table', {'class': 'table'}): print(a.text)Dryscrape installation:
sudo pip install dryscrape更多推荐
发布评论