Skip to main content

Calling 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.

GitHub Source

You can find source files in:

https://github.com/danelsan/parallel-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.5.tar.gz (5.8 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.5-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: parallel_reqs-0.0.5.tar.gz
  • Upload date:
  • Size: 5.8 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.5.tar.gz
Algorithm Hash digest
SHA256 765946da07d6329915c92c3040a1b88ebf4638b527723a416bff3b8c7001848f
MD5 62d7106742d77ef5f2d3328f1bbdb1bc
BLAKE2b-256 7c5bceea2da81e962b2566423476966d5fd450e3ecf43a54bf6ae5c43a162fc7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: parallel_reqs-0.0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 07b29e83bb2c82338b62cfb1e7c105343e899f6ff430b2107141d4700a9bbb98
MD5 d6973c7d31e159323ba181903f593e7b
BLAKE2b-256 0e6aad367441afe0571d3d7278c00a044ac2538f42c880bb22463dc0ca2f6dc0

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