Skip to main content

Proxy string to python-compatible dictionary converter.

Project description

proxyutils

Easy to use proxy parser library for Python's niche proxy format.

Install

pip install proxyutils

Basic usage

from proxyutils import Proxy

# get requests-supported proxy dict
proxy = Proxy("1.2.3.4:8080:user:pass")
proxy.proxies #{'http': 'http://user:pass@1.2.3.4:8080', 'https': 'http://user:pass@1.2.3.4:8080'}
proxy.get_proxy_parts() #{'user': 'user', 'pass': 'pass', 'ip': '1.2.3.4', 'port': 8080}

Works with all formats you need

odd_formatted_proxies = [
    #ip:port
    "1.1.1.1:8080",
    
    #ip:port[delimiters@:|]user:pass
    "1.1.1.1:8080:user:pass",
    "1.1.1.1:8080@user:pass",
    "1.1.1.1:8080|user:pass",
    
    #user:pass[delimiters@:|]ip:port
    "user:pass:1.1.1.1:8080",
    
    #with different schemes
    "http://user:pass:1.1.1.1:8080",
    "https://user:pass:1.1.1.1:8080",
    "socks4://user:pass:1.1.1.1:8080",
    "socks4a://user:pass:1.1.1.1:8080",
    "socks5://user:pass:1.1.1.1:8080",
    "socks5h://user:pass:1.1.1.1:8080",

    #host instead of ip
    "user:pass:sub.my-host.com:65535",
    "anotherhost.cz:65535:user:pass",

    #requests and httpx like proxy dictionaries
    {"http": "http://1.1.1.1:80", "https": "http://1.1.1.1:80"},
    {"http://": "http://1.1.1.1:80", "https://": "http://1.1.1.1:80"},
    #unformatted
    {"http": "1.1.1.1:80", "https": "1.1.1.1:80"},

    #proxy objects itself.
    Proxy("1.1.1.1:80"),
    Proxy("1.1.1.1:80:user:pass"),
]
proxies = [Proxy(p).proxies for p in odd_formatted_proxies]

Chrome proxy extension support

from proxyutils import Proxy, Extension
from selenium.webdriver.chrome.options import Options

proxy = Proxy("1.1.1.1:80:user:pass")
extension = Extension(proxy)
extension = Extension("1.1.1.1:80:user:pass")
extension = Extension({"http": "http://1.1.1.1:80:user:pass", "https": "http://1.1.1.1:80:user:pass"})


#zip
ext_zip_path = extension.create_extension_zip()
chrome_options = Options()
chrome_options.add_extension(ext_zip_path)

#folder
ext_folder_path = extension.create_extension_folder()
chrome_options = Options()
chrome_options.add_argument(f"--load-extension={ext_folder_path}") #deprecated in chrome 137+

...

extension.delete()

Enjoying this project? Show some love with a ⭐!

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

proxyutils-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

proxyutils-0.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file proxyutils-0.1.0.tar.gz.

File metadata

  • Download URL: proxyutils-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for proxyutils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e8ea6cdfda1285601b4cdcabc5a060a492ca14d1a00df1e32fb795141b52de1
MD5 041203ec9848e1c39457b45b656b8098
BLAKE2b-256 2c59a5c776e5e7970e2095a514de5223da0e2a9a72b40385f8096c2301356959

See more details on using hashes here.

File details

Details for the file proxyutils-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: proxyutils-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for proxyutils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5f24ed00c6cc5aeb3da68404a6e8380fd52ce4f165f4f3d6d81df6fa5d46b3d
MD5 254ef9853ddea57735eb16790f408ab4
BLAKE2b-256 b9ea37806d558c9d285da6f644f12fc91a8e3102edbcc6bbf73245311c8d7bdc

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