young marx
young marx

Reputation: 408

how to use bs4 to get to a link nested within a matched div element

Is there any way to get a the link out of an a element that's nested within a div element when all I can match is the div element? Something similar to the get_text() method but for links.

Here is what i have matched:

<div class="headline"><a href="http://www.davar1.co.il/116053/">כל שעה שווה לכם קצת יותר</a>

this is my bs4 call:

>>> headlines = davarsoup.select('.headline')

Upvotes: 0

Views: 45

Answers (1)

young marx
young marx

Reputation: 408

I figured it out! i thought i had tried this solution already, but apparently there was a typo. here is how i solved it:

>>> headlines = davarsoup.select('.headline > a')

sorry to bother anyone who might have bothered.

Upvotes: 1

Related Questions