Extracting href with Beautiful Soup

后端 未结 2 2016
鱼传尺愫
鱼传尺愫 2021-01-05 15:49

I use this code to get acces to my link :

links = soup.find(\"span\", { \"class\" : \"hsmall\" })
links.findNextSiblings(\'a\')
for link in links:
  print li         


        
2条回答
  •  伪装坚强ぢ
    2021-01-05 16:48

    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 in link:
      print "LINK = " + lien`
    

提交回复
热议问题