fix: Follow redirects during scraping (#3875)

This commit is contained in:
zeskeertwee 2024-07-10 18:49:13 +02:00 committed by GitHub
parent 47124488bb
commit fd2dc15a15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,7 +44,9 @@ async def safe_scrape_html(url: str) -> str:
"""
async with AsyncClient(transport=safehttp.AsyncSafeTransport()) as client:
html_bytes = b""
async with client.stream("GET", url, timeout=SCRAPER_TIMEOUT, headers={"User-Agent": _FIREFOX_UA}) as resp:
async with client.stream(
"GET", url, timeout=SCRAPER_TIMEOUT, headers={"User-Agent": _FIREFOX_UA}, follow_redirects=True
) as resp:
start_time = time.time()
async for chunk in resp.aiter_bytes(chunk_size=1024):