Made request.py
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
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"))
|
||||
Reference in New Issue
Block a user