Extracting href with Beautiful Soup

后端 未结 2 2028
鱼传尺愫
鱼传尺愫 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:30

    Links is still referring to your soup.find. So you could do something like:

    links = soup.find("span", { "class" : "hsmall" }).findNextSiblings('a')
    for link in links:
        print link['href']
        print link.string
    

提交回复
热议问题