Skip to main content

A Library to easily load/fetch proxy servers.

Project description

ProxyCycle

PyPI - Version PyPI - Python Version


Table of Contents

Installation

pip install proxycycle

Usage

### Initialize a proxy object
from proxycycle.Proxy import Proxy
from proxycycle.enums.scheme import Scheme
from proxycycle.enums.anonymity_level import AnonymityLevel
proxy1 = Proxy("127.0.0.1", 8080)
proxy2 = Proxy("127.0.0.1", 8080, Scheme.HTTP)
proxy3 = Proxy("127.0.0.1", 8080, anonymity_level=AnonymityLevel.Elite)
proxy4 = Proxy("127.0.0.1", 8080, Scheme.HTTP, AnonymityLevel.Elite)
proxy5 = Proxy.fromString("127.0.0.1:8080")
proxy6 = Proxy.fromString("http://127.0.0.1:8080")

### Initialize a proxyset
from proxycycle.ProxySet import ProxySet

ps1 = ProxySet([proxy2, proxy3, proxy4])

ps2 = ProxySet()
ps2.set_proxy(proxy1)

ps3 = ProxySet()
ps3.extend_with_proxysets(ps1, ps2)

with open('file.txt', 'r') as f:
    ps4 = ProxySet.fromFile(f)

### Initialize a proxyset without pre-known proxies
from proxycycle.api.proxyscrape import ProxyScrape
ps5 = ProxyScrape.fetch_proxyset(50)
len(ps5) # less or equal to 50   ^^ (this 50)

### Sometimes a single host can have multiple proxy servers
### In that case we can filter out some of the proxy entries.
from functools import partial

# Get the first (by index) proxy
ps1_deduplicated = ps1.deduplicate()

# Get proxies with port number > 8080
ps1_8080 = ps1.deduplicate(partial(filter, lambda x: x.port > 8080))

# Get the proxy with the highest anonymity level
def select_highest_anonymity_proxy(proxylist:list[Proxy]):
    proxy:Proxy|None = None
    for p in proxylist:
        if proxy is None:
            proxy = p
        elif p.anonymity_level > proxy.anonymity_level:
            proxy = p
    return proxy

ps1_highest_anonymity = ps1.deduplicate(select_highest_anonymity_proxy)

License

proxycycle is distributed under the terms of the MIT license.

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

proxycycle-1.2.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

proxycycle-1.2.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file proxycycle-1.2.1.tar.gz.

File metadata

  • Download URL: proxycycle-1.2.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for proxycycle-1.2.1.tar.gz
Algorithm Hash digest
SHA256 76b3043cc94c7c9b94b8c48dcd2495b08f592480b1b8d11ad2f2b44865c62b6c
MD5 1d03c3c24d336137c1e4e5e3ea5c6e5b
BLAKE2b-256 61cae909fe691ead15640f8a33ccdf21aec35216941d25fe1785f9f98f38c565

See more details on using hashes here.

File details

Details for the file proxycycle-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: proxycycle-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for proxycycle-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 32fac456fd7134dfa49ea7935fda798e70e684d141c26e3208c791c8a0a0da41
MD5 ec26a1d804b5dd1c0088af739b39d388
BLAKE2b-256 0867e8af339d285e9ae8cedd8c4f144f7f0d9f593cecbf68e8f75404311098a6

See more details on using hashes here.

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