May 25, 2019

299 words 2 mins read

rootVIII/proxy_requests

rootVIII/proxy_requests

a class that uses scraped proxies to make an http GET/POST request (Python requests)

repo name rootVIII/proxy_requests
repo link https://github.com/rootVIII/proxy_requests
homepage
language Python
size (curr.) 758 kB
stars (curr.) 319
created 2018-08-04
license MIT License

Python Proxy Requests | make an http GET/POST with a proxy scraped from https://www.sslproxies.org/

pypi.org: https://pypi.org/project/proxy-requests/ 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. Either copy the code and put where you want it, or download via pip: pip install proxy-requests (or pip3) from proxy_requests import ProxyRequests or if you need the Basic Auth subclass as well: from 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. System Requirements: Python 3 and the requests module. Runs on Linux and Windows (and Mac probably) - It may take a moment to run depending on the current proxy. Each request with a proxy is set with an 3 second timeout in the event that the request takes too long (before trying the next proxy socket in the queue). Proxies are randomly popped from the queue. The ProxyRequestBasicAuth subclass has the methods get(), get_with_headers(), post(), post_with_headers(), post_file(), and post_file_with_headers() that will override the Parent methods.

GET:

GET with headers:

POST:

POST with headers:

POST FILE:

POST FILE with headers:

GET with Basic Authentication:

GET with headers & Basic Authentication:

POST with Basic Authentication:

POST with headers & Basic Authentication:

POST FILE with Basic Authentication:

POST FILE with headers & Basic Authentication:

Response Methods Returns a string: print(r) Or if you want the raw content as bytes: r.get_raw() Get the response as JSON (if valid JSON): r.get_json() Get the response headers: print(r.get_headers()) Get the status code: print(r.get_status_code()) Get the proxy that was used to make the request: print(r.get_proxy_used()) To write raw data to a file (including an image):

comments powered by Disqus