I am struggling in scraping a certain row from this website.
First of all the table element has no class in it but I think i got a workaround to that.
My problem is that I want to print (or store in a variable or access the data) of a certain row, Let's say the row with the first value "Bollate": Screenshot of the row in the website
So I coded:
import requests
import bs4
URL = "http://www.centrometeolombardo.com/content.asp?CatId=332&ContentType=Dati"
response = requests.get(URL)
soup = bs4.BeautifulSoup(response.text, "lxml")
table = soup.find(text="Bollate").find_parent("table")
for a in table:
if a.text == "Bollate":
for val in a.parent-find_next_siblings():
print(val.text)
But I get getting:
Traceback (most recent call last):
File "/home/pi/Documents/Python/ngu.py", line 12, in <module>
if a.text == "Bollate":
File "/usr/lib/Python3/dist-packages/bs4/element.py", line 370, in _getattr_
self._class_._name_, attr))
AttributeError: 'NavigableString' object has no attribute 'text'
Which suggests me I am wrong since I get something that is not a text but I do not know how to overcome the problem.
Thanks all