No project description provided
Project description
py-valid-proxy
Installation
pip install py-valid-proxy
Usage
import pprint
from py_valid_proxy import valid_proxy
"""Valid proxy server ('alive' or 'dead')
Parameters
----------
host : str
IP Address
port : int
Port
scheme: str, optional
Scheme (default is 'http')
timeout: int, optional
Connect timeout is number of seconds (default is 5 sec.)
Returns
-------
None if proxy is 'dead'
dict if proxy is 'alive'
{
"scheme": str, # http, https
"host": str,
"port": int,
"export_address": list[str],
"anonymity": str, # transparent, anonymous, high_anonymous # noqa
"country": str # ISO Code
"response_time": float
}
"""
proxy_info = valid_proxy('8.219.97.248', 80, 'https', 10)
if proxy_info:
print('is alive')
pprint(proxy_info)
else:
print('is dead')
$ valid_proxy https://50.207.199.85:80 -l
Host: 50.207.199.85
Port: 80
Scheme: https
Response time: 0.51
Export address: []
Anonymity: transparent
Country : US
https://50.207.199.85:80 ... alive
$ valid_proxy http://50.207.199.85:80 -l
INFO:py_valid_proxy.main: HTTPConnectionPool(host='50.207.199.85', port=80): Max retries exceeded with url: http://httpbin.org/get?show_env=1&cur=1700497583.799429 (Caused by ProxyError('Unable to connect to proxy', ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f1219ed0750>, 'Connection to 50.207.199.85 timed out. (connect timeout=5)')))
http://50.207.199.85:80 ... is dead
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_valid_proxy-0.2.5.tar.gz
(3.1 MB
view hashes)
Built Distribution
Close
Hashes for py_valid_proxy-0.2.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fef46b04ecf1d5a0e89b2f31492a1bb026a008293523c9535454383dfe11b6a2 |
|
MD5 | 3b553a54225415dead91e09313bcdd54 |
|
BLAKE2b-256 | a1db6d9b3b8fc63272ea408afbef0f8925ff9946855ef9e1c242bc69258a6a86 |