N
N
Nanch2020-05-25 02:38:03
Python
Nanch, 2020-05-25 02:38:03

How to extract link from href?

I am writing a parser in python, I need to extract the link from href using BeautifulSoup so that I can then stuff them into the dictionary

h class="proposition_name"
<a> href="link">Jeep Grand Cherokee 2019a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2020-05-25
@Nanch

If html is like this:

<h1 class="proposition_name">
  <a href="ссылка">Jeep Grand Cherokee 2019</a>
</h1>
then like this:
link = soup.find('h1',class_='proposition_name').a.get('href')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question