Skip to content

Instantly share code, notes, and snippets.

@Findus23
Created January 27, 2018 20:55
Show Gist options
  • Save Findus23/3aaedbac0dd2520a9b65d0c9a6431b22 to your computer and use it in GitHub Desktop.
Save Findus23/3aaedbac0dd2520a9b65d0c9a6431b22 to your computer and use it in GitHub Desktop.
aiohttp
<ClientResponse(https://www.soeren-hentzschel.at/feed/) [200 OK]>
<CIMultiDictProxy('Date': 'Sat, 27 Jan 2018 20:53:38 GMT', 'Server': 'Apache', 'Last-Modified': 'Thu, 25 Jan 2018 23:03:14 GMT', 'ETag': '"a90d46d73255fadc47de09335c82e154"', 'X-Robots-Tag': 'noindex, follow', 'Link': '<https://www.soeren-hentzschel.at/wp-json/>; rel="https://api.w.org/"', 'Upgrade': 'h2,h2c', 'Connection': 'Upgrade', 'Vary': 'Accept-Encoding', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'Content-Type': 'application/rss+xml; charset=UTF-8')>
True
import asyncio
import aiohttp
import async_timeout
async def fetch(session, url):
with async_timeout.timeout(10):
async with session.get(url) as response:
print(response)
return await response.text()
async def main():
async with aiohttp.ClientSession() as session:
html = await fetch(session, 'https://www.soeren-hentzschel.at/feed/')
print(html)
print(html == "")
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment