Skip to main content

A lightweight network request framework

Project description

async-request

A lightweight network request framework based on requests & asyncio

install

pip install async_request

usage

import async_request

def parse_baidu(response):
    print(response.url, response.status_code)
    yield async_request.Request('https://cn.bing.com/', callback=parse_bing)

def parse_bing(response):
    print(response.url, response.status_code)
    yield async_request.Request('https://github.com/financialfly/async-request', callback=parse_github)

def parse_github(response):
    print(response.url, response.status_code)
    yield {'hello': 'github'}

def process_result(result):
    print(result)

reqs = [async_request.Request(url='https://www.baidu.com', callback=parse_baidu)]
c = async_request.Crawler(reqs, result_callback=process_result)
c.run()

And you'll see the result like this:

https://www.baidu.com/ 200
https://cn.bing.com/ 200
https://github.com/financialfly/async-request 200
{'hello': 'github'}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

async-request-0.151.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file async-request-0.151.tar.gz.

File metadata

  • Download URL: async-request-0.151.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.14.2 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for async-request-0.151.tar.gz
Algorithm Hash digest
SHA256 efd83cd17522ca00c21a8814e65807630fbb21f3ecf019cfcc227337baea380d
MD5 d9633b46f688e1cccde3400727c1b601
BLAKE2b-256 65122580eba4a8017408e8622df28301306edf2372b53fcbd6700d15ee235d9a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page