I'm trying to scrape a list of URLs from a page into a list to then loop a scraper through. The code below works but it only scrapes part of the URL instead of the whole one. Eg: /racecards/perth/13-05-21 instead of https://www.horseracing.net/racecards/racecards/perth/13-05-21.
How do I get the full URL?
import requests
from bs4 import BeautifulSoup
URL = "https://www.horseracing.net/racecards"
reqs = requests.get(URL)
content = reqs.text
soup = BeautifulSoup(content, "html.parser")
urls = []
for h in soup.findAll("h3"):
a = h.find("a")
try:
if "href" in a.attrs:
url = a.get("href")
urls.append(url)
except:
pass
for url in urls:
print(url)