Reputation:
I want to send HTTP request using urllib2 with proxy. The proxy will be in the database and each time send HTTP request sent by getting the proxy IP from table. Thank You.
Upvotes: 0
Views: 809
Reputation: 6255
I think this is the syntax youre looking for:
proxy = urllib2.ProxyHandler({'http': '177.124.160.6'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
urllib2.urlopen('http://www.google.com/search')
Alternatively in Python 2.7 requests library you can do:
requests.request(
method="GET",
url='https://www.google.com/search',
params= params,
headers=headers,
proxies = proxy)
Where each input is an object with key value pairs
Upvotes: 1