Created
June 1, 2020 11:38
-
-
Save pavel-kolla-kampiki/b79d0b2a9f6c3a98402968393168432e to your computer and use it in GitHub Desktop.
to be run from root of https://github.com/EzyInsights/ezyinsights-acquisition-blurr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import asyncio | |
import uvloop | |
from blurr.ezylogging import get_logger | |
from blurr.management.model import HTTPSessionContext | |
from blurr.model import HTTPAcquirerStrategy | |
from blurr.util.http import http_session_factory | |
async def do(loop): | |
logger = get_logger(dict(debug=True, log_as_json=False)) | |
ctx = HTTPSessionContext( | |
loop=loop, | |
timeout=dict(total=65, sock_read=30, sock_connect=30), | |
connector=dict(limit=1, ttl_dns_cache=300, limit_per_host=0), | |
) | |
session = http_session_factory(ctx) | |
strategy = HTTPAcquirerStrategy.default_strategy() | |
url = 'https://www.new-facts.eu/proteste-in-den-usa-reissen-nicht-ab-379501.html' | |
async with session.get(url, headers=strategy.headers, read_until_eof=False, allow_redirects=False) as response: | |
logger.info(response.status) | |
logger.info(response.headers) | |
body = await response.read() | |
logger.info(body[:100]) | |
if __name__ == '__main__': | |
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(do(loop)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment