BeautifulSoup: extract text from anchor tag

后端 未结 5 1887
误落风尘
误落风尘 2020-12-01 00:34

I want to extract:

  • text from following src of the image tag and
  • text of the anchor tag which is inside the div class data
5条回答
  •  一向
    一向 (楼主)
    2020-12-01 01:25

    In my case, it worked like that:

    from BeautifulSoup import BeautifulSoup as bs
    
    url="http://blabla.com"
    
    soup = bs(urllib.urlopen(url))
    for link in soup.findAll('a'):
            print link.string
    

    Hope it helps!

提交回复
热议问题