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
Release history Release notifications | RSS feed
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.152.tar.gz
(3.9 kB
view hashes)