{
"info": {
"author": "James Loye Colley",
"author_email": "",
"bugtrack_url": null,
"classifiers": [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3"
],
"description": "## Python Proxy Requests | make an http GET/POST with a proxy scraped from https://www.sslproxies.org/\n
\nThe 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.\n
\nEither copy the code and put where you want it, or download via pip:\n
\npip install proxy-requests (or pip3)\n
\nfrom proxy_requests import ProxyRequests\n
\nor if you need the Basic Auth subclass as well:\n
\nfrom proxy_requests import ProxyRequests, ProxyRequestsBasicAuth\n
\nIf 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.\n
\nSystem Requirements: Python 3 and the requests module.\n
\nRuns on Linux and Windows (and Mac probably) - It may take a moment to run depending on the current proxy.\n
\nEach request with a proxy is set with a 3 second timeout in the event that the request takes too long (before trying the next proxy socket in the queue).\n
\nThe 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.\n
\n\nGET:\n
\n \nr = ProxyRequests(\"https://api.ipify.org\")\nr.get()\n \n\n\nGET with headers:\n\n \nh = {\"User-Agent\": \"NCSA Mosaic/3.0 (Windows 95)\"}\nr = ProxyRequests(\"url here\")\nr.set_headers(h)\nr.get_with_headers()\n \n\n\nPOST:\n\n \nr = ProxyRequests(\"url here\")\nr.post({\"key1\": \"value1\", \"key2\": \"value2\"})\n \n\n\nPOST with headers:\n\n \nr = ProxyRequests(\"url here\")\nr.set_headers({\"name\": \"rootVIII\", \"secret_message\": \"7Yufs9KIfj33d\"})\nr.post_with_headers({\"key1\": \"value1\", \"key2\": \"value2\"})\n \n\n\nPOST FILE:\n\n \nr = ProxyRequests(\"url here\")\nr.set_file({'file': open('test.txt', 'rb')})\nr.post_file()\n \n\n\nPOST FILE with headers:\n\n \nh = {\"User-Agent\": \"NCSA Mosaic/3.0 (Windows 95)\"}\nr = ProxyRequests(\"url here\")\nr.set_headers(h)\nr.set_file({'file': open('test.txt', 'rb')})\nr.post_file_with_headers()\n \n\n\nGET with Basic Authentication:\n\n \nr = ProxyRequestsBasicAuth(\"url here\", \"username\", \"password\")\nr.get()\n \n\n\nGET with headers & Basic Authentication:\n\n \nh = {\"User-Agent\": \"NCSA Mosaic/3.0 (Windows 95)\"}\nr = ProxyRequestsBasicAuth(\"url here\", \"username\", \"password\")\nr.set_headers(h)\nr.get_with_headers()\n \n\n\nPOST with Basic Authentication:\n\n \nr = ProxyRequestsBasicAuth(\"url here\", \"username\", \"password\")\nr.post({\"key1\": \"value1\", \"key2\": \"value2\"})\n \n\n\nPOST with headers & Basic Authentication:\n\n \nr = ProxyRequestsBasicAuth(\"url here\", \"username\", \"password\")\nr.set_headers({\"header_key\": \"header_value\"})\nr.post_with_headers({\"key1\": \"value1\", \"key2\": \"value2\"})\n \n\n\nPOST FILE with Basic Authentication:\n\n \nr = ProxyRequestsBasicAuth(\"url here\", \"username\", \"password\")\nr.set_file({'file': open('test.txt', 'rb')})\nr.post_file()\n \n\n\nPOST FILE with headers & Basic Authentication:\n\n \nh = {\"User-Agent\": \"NCSA Mosaic/3.0 (Windows 95)\"}\nr = ProxyRequestsBasicAuth(\"url here\", \"username\", \"password\")\nr.set_headers(h)\nr.set_file({'file': open('test.txt', 'rb')})\nr.post_file_with_headers()\n \n \nprint(r)\nr.get_raw()\nr.get_json()\nprint(r.get_headers())\nprint(r.get_status_code())\nprint(r.get_proxy_used())\n\n \n\nurl = 'https://www.restwords.com/static/ICON.png'\nr = ProxyRequests(url)\nr.get()\nwith open('out.png', 'wb') as f:\n f.write(r.get_raw())\n\n \n\n\n \nimport json\nwith open('test.txt', 'w') as file_out:\n json.dump(r.get_json(), f)\n \n\n