Changed Google-Search to Youtube (fix)

This commit is contained in:
Lukas Blacha
2023-02-08 12:15:03 +01:00
parent 7ffc356b1c
commit 9b1e473ec1

View File

@@ -97,8 +97,8 @@ else:
p = {"search_query": query} p = {"search_query": query}
# Spoof a user agent header or the request will immediately fail # Spoof a user agent header or the request will immediately fail
h = {"User-Agent": "Mozilla/5.0"} h = {"User-Agent": "Mozilla/5.0"}
async with aiohttp.ClientSession() as client: with aiohttp.ClientSession() as client:
async with client.get("https://www.youtube.com/results", params=p, headers=h) as resp: with client.get("https://www.youtube.com/results", params=p, headers=h) as resp:
dom = await resp.text() dom = await resp.text()
# open("debug.html", "w").write(dom) # open("debug.html", "w").write(dom)
found = re.findall(r'href"\/watch\?v=([a-zA-Z0-9_-]{11})', dom) found = re.findall(r'href"\/watch\?v=([a-zA-Z0-9_-]{11})', dom)