How to use CSS selectors to retrieve specific links lying in some class using BeautifulSoup?

后端 未结 3 1216
既然无缘
既然无缘 2020-12-13 14:23

I am new to Python and I am learning it for scraping purposes I am using BeautifulSoup to collect links (i.e href of \'a\' tag). I am trying to collect the links under the \

3条回答
  •  孤街浪徒
    2020-12-13 14:53

    import bs4 , requests
    
    res = requests.get("http://allevents.in/lahore/")
    soup = bs4.BeautifulSoup(res.text)
    for link in soup.select('a[property="schema:url"]'):
        print link.get('href')
    

    This code will work fine!!

提交回复
热议问题