from selectolax.parser import HTMLParser import requests def getLinks(url): resp = requests.get(url, timeout=10) resp.raise_for_status() tree = HTMLParser(resp.text) links = [a.attributes.get('href') for a in tree.css('a[href]')] return links print(getLinks("https://google.com"))