Skip to main content

Sync & asyncio (Requests & AIOHTTP) proxy rotator + utils for actproxy API & services.

Project description

actproxy (Python Package)

This Python package provides actproxy API access and proxy rotation methods for requests (synchronous) and aiohttp (asyncio).

Quick-Start (AIOHTTP)

import actproxy
from aiohttp import ClientSession


async def main():
    actproxy_api_key = "xxxxxxxxxxxxxxxxxxxxxxxx"
    # Initialize API. Also returns your proxies.
    await actproxy.aioinit(actproxy_api_key)
    # Use a new AIOHTTP connector which rotates & uses the next proxy.
    async with ClientSession(connector=actproxy.aiohttp_rotate()) as session:
        url = "http://dummy.restapiexample.com/api/v1/employees"
        async with session.get(url) as resp:
            if resp.status == 200:
                resp_json = await resp.json()
                print(resp_json)

Quick-Start (Requests)

import actproxy
import requests

actproxy_api_key = "xxxxxxxxxxxxxxxxxxxxxxxx"
# Initialize API. Also returns your proxies.
actproxy.init(actproxy_api_key)
url = "http://dummy.restapiexample.com/api/v1/employees"
resp = requests.get(url, proxies=actproxy.rotate())
if resp.status_code == 200:
    resp_json = resp.json()
    print(resp_json)

Methods

actproxy.aioinit(api_key): Fetches your proxies from ActProxy & returns them. Must be run before other aiohttp functions.

actproxy.init(api_key): Fetches your proxies from ActProxy & returns them. Must be run before other synchronous functions.

actproxy.aiohttp_rotate(): Returns an aiohttp connector which uses the next proxy from your list.

actproxy.rotate(): Returns the next proxy from your list. Return variable is suitable for use with requests[socks].

actproxy.random_proxy(): Returns a random proxy from your list. Return variable is suitable for use with requests[socks].

actproxy.aiohttp_random(): Returns an aiohttp connector which uses uses a random proxy from your list.

actproxy.one_hot_proxy(): Similar to rotate() but returns a single proxy dict/object for use in places other than aiohttp or requests.

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

actproxy-0.1.2.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

actproxy-0.1.2-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