Skip to content

Instantly share code, notes, and snippets.

@amarynets
Created July 11, 2018 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amarynets/25eb8479ff6463ffa41333320b4a1b4c to your computer and use it in GitHub Desktop.
Save amarynets/25eb8479ff6463ffa41333320b4a1b4c to your computer and use it in GitHub Desktop.
aiohttp does a 10 redirection
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