0

I am new to HTML and am trying to scrape some web data using beautifulsoup.

I have am grabbing this from the website and trying to extract title and link.

value = <a class="AnchorLink News__Item external flex flex-row" href="https://abcnews.go.com/Politics/biden-harris-make-appearance-historic-democratic-ticket/story?id=72327968" name="&amp;lpos=toolkit" tabindex="0" target="_self"><div class="News__Content__Container"><div class="News__Item__Headline">Biden and Harris make 1st joint appearance </div></div></a>

I am able to get the title like this

value.find('div').get_text()

I would like to grab the link (href) from value, but am not sure where specifically to look in the beautifulsoup docs. I know I can do it with regex but wondering if there's a simpler way with beautifulsoup.

value.find('a') 

returns None!

laurakoco
  • 59
  • 3
  • If you knew where to look in the docs, you probably also knew what was there. A minimum of effort is expected. Your question comes down to this: https://stackoverflow.com/questions/1080411/retrieve-links-from-web-page-using-python-and-beautifulsoup – Grismar Aug 13 '20 at 04:18
  • Yes, this does - thank you By the way, I have been searching for a while, but I don't know the HTML terminology, which has made it difficult – laurakoco Aug 13 '20 at 04:23

1 Answers1

0
value['href']

seems to do the trick

yeiniel
  • 2,416
  • 15
  • 31
laurakoco
  • 59
  • 3