Skip to main content

Basic async requester

Project description

Project description

Asyncrequester is a library that makes it easy to make async requests with grequests library.

Install

pip install asyncrequester

Quick start

from asyncrequester import get_async_requests,get_single_request

headers = {
'authority': 'www.google.com',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36',
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'sec-fetch-site': 'none',
'sec-fetch-mode': 'navigate',
'sec-fetch-dest': 'document',
'accept-language': 'en'
}

urls = ["https://www.google.com"]*100 

responses = get_async_requests(urls,20,0.5,headers)
# it will make 20 requests every 0.5 seconds and return all responses
# 'headers' is optional

response = get_single_request(urls[0])
# it makes simple get request

Output

Total web page count: 100
0 Waiting
20 Waiting
40 Waiting
60 Waiting
80 Waiting
100 Waiting
Succes: 100 , Fail: 0
It took 7.0120155811309814 seconds to retrieve 100 webpages.

Parameters

  • urls: url list
  • max_connections: max connections at once
  • time_delay: delay for every request
  • headers: headers (Optinal)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

asyncrequester-0.1.3-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

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