生の (圧縮された) コンテンツを取得する必要があります。私の目標は、そのままS3に保存することです。それは簡単ですrequests:
import requests
response = requests.get('http://google.com', stream=True)
content = response.raw.read() # b'\x1f\x8b\x08\x00\x00\x00\x00...'
ただし、aiohttp私は常に解凍済みのコンテンツを取得します。
import asyncio
import aiohttp
async def download(url):
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
content = await response.content.read() # b'<!doctype html><html...'
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(download('http://google.com'))