Skip to main content

Call parallel request Pyhton

Project description

Parallel Requests

Parallel Requests is a Python project that allows you to execute HTTP requests in parallel using the asyncio and aiohttp libraries. This tool is designed to improve efficiency and reduce waiting time when making multiple HTTP requests. With Parallel Requests, you can send GET, POST, PUT, and DELETE requests simultaneously, collecting responses asynchronously and easily managing the results.

**Features**:

/ Parallel execution of HTTP requests: Send multiple requests simultaneously to reduce waiting times.

- Support for common HTTP methods: Perform GET, POST, PUT, and DELETE requests.

- Asynchronous management: Utilizes asyncio and aiohttp for efficient request handling.

- Execution time calculation: Measures the time taken to execute each request.

- Ease of use: Simple interface for adding and managing requests.

Installation

For installation by gih write

make install

Puoi installare Parallel Requests usando il file setup.py. Nella directory principale del progetto, esegui il seguente comando:

pip install parallel_reqs

Example

from parallel_reqs import RequestExecutor 
from parallel_reqs import Request

# Lista di URL di esempio
urls = [
    "https://www.google.com",
    "https://www.bing.com",
    "https://www.yahoo.com",
    "https://www.wikipedia.org",
    "https://www.imdb.com",
    "https://www.amazon.com",
    "https://www.ebay.com",
    "https://www.facebook.com",
    "https://www.twitter.com",
    "https://www.instagram.com",
    "https://www.corriere.it",
    "https://www.repubblica.it",
    "https://www.ansa.it",
    "https://www.rainews.it",
    "https://www.sky.it",
    "https://www.msn.com",
    "https://www.aol.com",
    "https://www.cnn.com",
    "https://www.foxnews.com",
    "https://www.bbc.com",
    "https://www.aljazeera.com",
    "https://www.nbcnews.com",
    "https://www.cbsnews.com",
    "https://www.abcnews.go.com",
    "https://www.npr.org",
    "https://www.pbs.org",
    "https://www.huffpost.com",
    "https://www.buzzfeed.com",
    "https://www.vox.com",
    "https://www.slate.com",
    "https://www.theverge.com",
    "https://www.wired.com",
    "https://www.arstechnica.com",
    "https://www.engadget.com",
    "https://www.cnet.com",
    "https://www.zdnet.com",
    "https://www.techcrunch.com",
    "https://www.theatlantic.com",
    "https://www.newyorker.com",
    "https://www.harpersbazaar.com",
    "https://www.vanityfair.com",
    "https://www.gq.com",
    "https://www.esquire.com",
    "https://www.menshealth.com",
    "https://www.womenshealthmag.com",
    "https://www.shape.com",
    "https://www.self.com",
    "https://www.cosmopolitan.com",
    "https://www.glamour.com",
    "https://www.allure.com",
    "https://www.vogue.com",
    "https://www.elle.com",
    "https://www.harpersbazaar.com",
    "https://www.marieclaire.com"
]

                                                                                   
def main():
        print("Urls: ", len(urls))
        executor = RequestExecutor()       
        try:
            for u in urls:
                executor.add_request(Request.create(url=u, method="GET"))
        except Exception as e:    
            print(e)

        responses = executor.run()
        print("Responses: ", len(responses))
        for response in responses: 
            print(f"Status Code: {response.status_code}, Execution Time: {response.execution_time} sec") 

        print( "Total: exec" , executor.execution_time)


main()

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

parallel_reqs-0.0.4.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parallel_reqs-0.0.4-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file parallel_reqs-0.0.4.tar.gz.

File metadata

  • Download URL: parallel_reqs-0.0.4.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for parallel_reqs-0.0.4.tar.gz
Algorithm Hash digest
SHA256 16f3b662d84552304bffe5bab0c44952de48d215352b1eca84c289615eedb30e
MD5 1bb343fee5dc243743c470d3347281a7
BLAKE2b-256 eca60c021c088d12e89657257a960f23db72dde39d1238b6e74330fc967b6bda

See more details on using hashes here.

File details

Details for the file parallel_reqs-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: parallel_reqs-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for parallel_reqs-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9907c4e6bf23549d5b72341315d8c14be66b94d6b05cbd965769e64e7bbc6146
MD5 aeaf825656faafa671b480a5b7139e0f
BLAKE2b-256 6ab33a77021c37c7d24b579ebc382a5289e0a7429efa1b9278053d2ed98beb3a

See more details on using hashes here.

Supported by

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