Hello,
I can't figure out why BS can't find the (first) element that holds the "latitude" attribute:
Thank you.
---
Edit: It works if I use the following to find the element:
I can't figure out why BS can't find the (first) element that holds the "latitude" attribute:
for item in glob.glob("index.*"): soup = BeautifulSoup(open(item, 'r',encoding='utf-8'), "lxml") #OK url = soup.find("link",{"rel":"canonical"}).get("href") if url: print(url) else: print("No URL") """ <div id="blah" latitude="1.23" longitude="4.56" > """ lat = soup.find("div").get("latitude") lat = soup.find("div","latitude") #no better if lat: print("Found lat=",lat) else: print("No lat")Is there something obvious I missed?
Thank you.
---
Edit: It works if I use the following to find the element:
lat = soup.find("div",{"id":"99"}).get("latitude") if lat: print("Found lat=",lat) else: print("No lat")