How To Retrieve These Elements From A Webpage?
I have a webpage in HTML with these elements:
Adding on to the examples below but to only use the the href contained in the div
>>> alldiv = soup.findAll('div', { "class" : "content_page" })
>>> for div in alldiv: print div.a
...
<a href="/earth" class="nametessera">earth</a>
<a href="/world" class="nametessera">world</a>
<a href="/planet" class="nametessera">planet</a>
>>> for div in alldiv: print div.a['href']
...
/earth
/world
/plan
Similarly you could also do
allHref = soup.findAll('a', { "class" : "nametessera" })
Post a Comment for "How To Retrieve These Elements From A Webpage?"