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

Uploaded Python 3

File details

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

File metadata

  • Download URL: parallel_reqs-0.0.2.tar.gz
  • Upload date:
  • Size: 5.0 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.2.tar.gz
Algorithm Hash digest
SHA256 669c96718086caa8d1d8af5f7bbeb9ec61cda81f79a56deb46a67f06bbcc5322
MD5 7275d5048c7982de587596756eb8aa13
BLAKE2b-256 cbd96c165cf3d07500612f5bc02367453cb35e7fb7d4abfa0126be114f817bc2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: parallel_reqs-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5b21d4df0650a740444111b3771a8e50657b88a17df85dd91b89fb34ac9d0c50
MD5 17260e37f7ffc006cb654c116c79141f
BLAKE2b-256 149808089d08eacf9916df833de3bc6789381fd542f5a2654ca241c90b63b80d

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