def _fetch_page(self, request):
try:
with aiohttp.Timeout(10):
async with aiohttp.get(request['url'], params=request['params'], headers=request['headers']) as response:
try:
assert response.status == 200
if request['type'] == 'json':
content = await response.json()
else:
content = await response.text(request['type'])
obj = {'order':request['order'], 'content':content}
redis_push(self.redis, self.content_key, obj)
except AssertionError:
logging.warning('{} {}'.format(response.status, url))
except: # kinds of error, not only asyncio.TimeoutError
#redis_push(self.redis, self.request_key, request)
pass
评论列表
文章目录