A wrapper for the Python 3 requests module
Project description
Python Proxy Requests | make an http GET/POST with a proxy scraped from https://www.sslproxies.org/
The ProxyRequests class first scrapes proxies from the web. Then it recursively attempts to make a request if the initial request with a proxy is unsuccessful. System Requirements: Python 3 and the requests module.
Youtube Demo: https://youtu.be/isxJeqo_sBA
Runs on Linux and Windows (and Mac probably)-It may take a moment to run depending on current proxy.
Either copy the code and put where you want it, or download via pip:
pip3 install proxy-requests
from proxy_requests.proxy_requests import ProxyRequests
or if you need the Basic Auth subclass as well:
from proxy_requests.proxy_requests import ProxyRequests, ProxyRequestsBasicAuth
If the above import statement is used, method calls will be identical to the ones shown below. Pass a fully qualified URL when initializing an instance.
The ProxyRequestBasicAuth subclass has get(), get_with_headers(), post(), post_with_headers(), and post_file() methods that will override the Parent methods.
example GET:
r = ProxyRequests("https://api.ipify.org")
r.get()
example GET with headers:
h = {"User-Agent": "NCSA Mosaic/3.0 (Windows 95)"}
r = ProxyRequests("url here")
r.set_headers(h)
r.get_with_headers()
example POST:
r = ProxyRequests("url here")
r.post({"key1": "value1", "key2": "value2"})
example POST with headers:
r = ProxyRequests("url here")
r.set_headers({"name": "rootVIII", "secret_message": "7Yufs9KIfj33d"})
r.post_with_headers({"key1": "value1", "key2": "value2"})
example POST FILE:
r = ProxyRequests("url here")
r.set_file({'file': open('test.txt', 'rb')})
r.post_file()
example GET with Basic Authentication:
r = ProxyRequestsBasicAuth("url here", "username", "password")
r.get()
example GET with headers & Basic Authentication:
h = {"User-Agent": "NCSA Mosaic/3.0 (Windows 95)"}
r = ProxyRequestsBasicAuth("url here", "username", "password")
r.set_headers(h)
r.get_with_headers()
example POST with Basic Authentication
r = ProxyRequestsBasicAuth("url here", "username", "password")
r.post({"key1": "value1", "key2": "value2"})
example POSTwith headers & Basic Authentication
r = ProxyRequestsBasicAuth("url here", "username", "password")
r.set_headers({"header_key": "header_value"})
r.post_with_headers({"key1": "value1", "key2": "value2"})
example POST FILE with Basic Authentication:
r = ProxyRequestsBasicAuth("url here", "username", "password")
r.set_file({'file': open('test.txt', 'rb')})
r.post_file()
Response Methods:
print(r)
print(r.get_headers())
print(r.get_status_code())
print(r.to_json())
print(r.get_proxy_used())
To write response a to a file (including an image):
r.response_to_file()
Or if you want to write raw content yourself:
r.get_raw()
The to_json() method is not intended to be used for a string of HTML
This was developed on Ubuntu 16.04.4 LTS.
Author: James Loye Colley 04AUG2018
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
Built Distribution
Hashes for proxy_requests-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22239cc8de5dc9a44b3a33993b27c0877a4fbdec7c73ba1daf617beadba48261 |
|
MD5 | 10c8d81d8376bf3f07bf3774a031bccc |
|
BLAKE2b-256 | ed717a4596ade55fff123f734c750070074f42b3012926b0ae0e6f9d92ccb014 |