Extracting Href With Beautiful Soup
I use this code to get acces to my link : links = soup.find('span', { 'class' : 'hsmall' }) links.findNextSiblings('a') for link in links: print link['href'] print link.string
Solution 1:
Links is still referring to your soup.find. So you could do something like:
links = soup.find("span", { "class" : "hsmall" }).findNextSiblings('a')
forlinkin links:
printlink['href']
print link.string
Solution 2:
Okay, it works now with following code :
linkSpan = soup.find("span", { "class" : "hsmall" })
link = [tag.attrMap['href'] for tag in linkSpan.findAll('a', {'href': True})]
for lien inlink:
print"LINK = " + lien`
Baca Juga
- How Web Scrape Data From This Line .. There Is No Div And No Class Element I Can't Find.i Want To Extract Data From That Line??how
- Find Next Siblings Until A Certain One Using Beautifulsoup
- In A Flask Function Which Returns `send_file`, The Code Doesn't Appear To Run On Subsequent Requests, Yet The File Still Downloads. Why?
Post a Comment for "Extracting Href With Beautiful Soup"