mardi 26 mars 2019

which CSS selector should I use for accessing the numbers on a graph in a website ( python)

I am trying to exatract some numbers from a graph on this page ( https://www.zoopla.co.uk/local-info/?outcode=cm15&incode=9bq )

There are 5 tabs in that graph.

I am interested in the 5th tab (Newspapers).

When I run this piece of code, I get some info about the first tabbed graph.

but soup.find_all('',id='neighbours-newspapers') returns a blank.

from bs4 import BeautifulSoup as bs
import requests

res=requests.get('https://www.zoopla.co.uk/local-info/?outcode=cm15&incode=9bq')
soup = bs(res.content, 'lxml')

housing = [item.text.replace('\n','').strip() for item in soup.find_all('',id='local-info-neighbours')]
print(housing)

newspapers = [item.text.replace('\n','').strip() for item in soup.find_all('',id='neighbours-newspapers')]
print(newspapers)

I am not sure how to access an id within an id if that's what it is. Could someone help please?




Aucun commentaire:

Enregistrer un commentaire