dimanche 22 septembre 2019

How to extract href attribute in html source code

This is HTML source code that I am dealing with:

<a href="/people/charles-adams" class="gridlist__link">

So what I want to do is to extract the href attribute, in this case would be "/people/charles-adams", with beautifulsoup module. I need this because I want to get html source code with soup.findAll method for that particular webpage. But I am struggling to extract such attribute from the webpage. Could anyone help me with this problem?

P.S. I am using this method to get html source code with Python module beautifulSoup:

request = requests.get(link, headers=header)
html = request.text
soup = BeautifulSoup(html, 'html.parser')

Thanks in advance for anyone answering my question.




Aucun commentaire:

Enregistrer un commentaire