12 lines
303 B
Python
12 lines
303 B
Python
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"))
|