connecting to a website using proxies and urllib?
If the proxy is 200.217.241.76
and the port is 80
how can i connect to google.com
and read the html code using that proxy?
My problem is to establish the connection i know how to read the html file when i get it, i want to automate a script that keep on reading different html files and save the data.
what i have now :
import urllib
html = urlli开发者_运维百科b.openurl("http://google.com").read()
# do stuff with html
an example would be great !
urllib honors the system proxy settings:
The urlopen() function works transparently with proxies which do not require authentication. In a Unix or Windows environment, set the http_proxy, or ftp_proxy environment variables to a URL that identifies the proxy server before starting the Python interpreter. For example (the '%' is the command prompt):
> % http_proxy="http://www.someproxy.com:3128"
> % export http_proxy
> % python ...
enter link description here
精彩评论