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.1.tar.gz (2.6 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.1-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file parallel-reqs-0.0.1.tar.gz.

File metadata

  • Download URL: parallel-reqs-0.0.1.tar.gz
  • Upload date:
  • Size: 2.6 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.1.tar.gz
Algorithm Hash digest
SHA256 d5a9d5e512897d58133dea3784c862d37560ee2fd479fb5f05b1e649122342ee
MD5 9c276a225f0c78b688a926407d468764
BLAKE2b-256 d53f3b57d7f90e77baca581b89b9bb160bb31628c121530516a8faac0b8744a8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: parallel_reqs-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 71f878a483bc72fa954e1f211962a6cb4607d0745821a87f471ca144d49ca36d
MD5 e64c54adb3179ede07aa6379d3385edf
BLAKE2b-256 ea16d2f4a2a5bb87baa140c2a85bd86001a608fd3fbda05b318b257ed7de9bbc

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