January 2019
Beginner to intermediate
776 pages
19h 58m
English
Let us send our HTTP request through a public domain proxy server.
Listing 4.5 explains proxying web requests across a proxy server as follows:
#!/usr/bin/env python # Python Network Programming Cookbook -- Chapter - 4 # This program requires Python 3.5.2 or any later version # It may run on any other version with/without modifications. # # Follow the comments inline to make it run on Python 2.7.x. import urllib.request, urllib.parse, urllib.error # Comment out the above line and uncomment the below for Python 2.7.x. #import urllib URL = 'https://www.github.com' PROXY_ADDRESS = "165.24.10.8:8080" # By Googling free proxy server if __name__ == '__main__': proxy = urllib.request.ProxyHandler({"http" : PROXY_ADDRESS}) opener ...Read now
Unlock full access