I have come across a task where I have to retrieve information from a website using a crawler. (url: https://www.onepa.gov.sg/cat/adventure)
The website has multiple products. For each product, it contains link that directs us to a webpage of that individual product, and I want to collect all of the links.
For example, one of the product has name: KNOTTY STUFF, and I expect to get the href of /class/details/c026829364
import requests
from bs4 import BeautifulSoup
def get_soup(url):
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text, features="html.parser")
return soup
url = "https://www.onepa.gov.sg/cat/adventure"
soup = get_soup(url)
for i in soup.findAll("a", {"target": "_blank"}):
print(i.get("href"))
The output is https://tech.gov.sg/report_vulnerability https://www.pa.gov.sg/feedback
Which does not include what I was looking for: /class/details/c026829364
I appreciate any helps or assistance, thank you!