I have code that only works partially:
from pyquery import PyQuery as pq
import requests
url = SAMPLE_URL.com
content = requests.get(url).content
doc = pq(content)
Latest_Report = doc(".head+ .post .heading")
Latest_Report.text()
I am able to get the Text element with this. But I want to use the URL available here.
print(Latest_Report)
What is the best way to get the href:
<a class="heading" href="URL_WANTED">ABC’s September Construction Backlog Indicator Dips, Yet Contractors Remain Confident</a>
You can use
Latest_Report.attr('href')
to access thehref
attribute of the element.