aiostar.tasks.Request.Request

Here are the examples of the python api aiostar.tasks.Request.Request taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

0 Source : __init__.py
with MIT License
from lvyunze

    async def download_file(
            self,
            url,
            save_path,
            callback,
            headers=None,
            cookies=None,
            meta={}
    ):
        default_headers = {
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
        }
        if not headers:
            headers = default_headers
        try:
            _meta = {
                'meta': meta,
                'url': url,
                'save_path': save_path,
                'callback': callback.__name__
            }
            yield Request(
                url=url,
                headers=headers,
                callback=self.save_file,
                meta=_meta,
                cookies=cookies
            )
        except Exception as e:
            print(e)
            yield self.log('[DOWNLOAD-EXCEPTION] {}'.format(traceback.format_exc()))

    async def save_file(self, request, response):