SirDodo
SirDodo

Reputation: 3

Can't get specific data from a HTML site in Python (3.6)

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

Upvotes: 0

Views: 147

Answers (1)

Mohammad Yusuf
Mohammad Yusuf

Reputation: 17074

BeautifulSoup, 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

Upvotes: 1

Related Questions