I'm currently trying to audit a large number of redirect URL handles to make sure that their destinations are still valid.
I'm using aiohttp to go through the large volume in order to produce a report.
try:
with aiohttp.Timeout(timeout):
async with session.get(url) as resp:
return {"Handle URL": url,
"Status Code": resp.status,
"Redirects": resp.url != url,
"Resolving URL": resp.url,
"Success": resp.status == 200,
"Message": ""}
except asyncio.TimeoutError:
return {"Handle URL": url,
"Success": False,
"Message": "Handle server timed out. >{} seconds".format(timeout)}
For the most part, this has been fine for identifying which URL redirect no longer sends to a valid URL. However, I'd really like to know the final address where times out.
Any ideas?
The only way to do it is disabling redirects by allow_redirects=False and performing redirections manually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With