Created
July 11, 2018 08:37
-
-
Save amarynets/25eb8479ff6463ffa41333320b4a1b4c to your computer and use it in GitHub Desktop.
aiohttp does a 10 redirection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import aiohttp | |
url1 = 'https://www.jonathanadler.com/art/by-artist/slim-aarons/slim-aarons-andldquo%3Bverbier-vacationandrdquo%3B-photograph/19135.html' | |
url2 = 'https://www.jonathanadler.com/furniture/by-category/benches-and-ottomans/x-bench/24-1900005.html?dwvar_24-1900005_base=NoBase&dwvar_24-1900005_quickShip=custom&dwvar_24-1900005_fabric=AntwerpSea&dwvar_24-1900005_fabricType=TexturedWoven' | |
async def request(url): | |
async with aiohttp.ClientSession() as session: | |
async with session.get(url) as response: | |
return response, await response.text() | |
async def check(url): | |
response, text = await request(url) | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(check(url1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment