2

如何使用 GET 请求加载 Zip 文件?

我在我的 Python 应用程序中使用 asyncio 和 aiohttp。那是我的代码:

async def fetch_page(session, url):
    with aiohttp.Timeout(10):
        async with session.get(url) as response:
            assert response.status == 200
            return await response.read()

loop = asyncio.get_event_loop()
links = ['http://www2.census.gov/census_2010/04-Summary_File_1/Louisiana/la2010.sf1.zip']
for link in links:
    with aiohttp.ClientSession(loop=loop) as session:
        response = loop.run_until_complete(fetch_page(session, url=link))
        print(type(response))

然后我得到 asyncio.TimeoutError

4

0 回答 0