I have a python script that will be run as an exe (packaged using py2exe) on a machine without Python installed. I currently have my proxy information written into the script using a proxy handler with urllib2 (see code below), but I would like to pass the user and pw as parameters written via command line, which I'm using to run the exe. Anyone have any idea how to do this? Any help is appreciated!
def get_response(url, query='', get_json=True):
opener = urllib2.build_opener(
urllib2.HTTPHandler(),
urllib2.HTTPSHandler(),
urllib2.ProxyHandler(
{'https': 'http://user:password@myIPaddress:8080',
'http': 'http://user:password@myIPaddress:8080'}
))
urllib2.install_opener(opener)
encoded = urllib.urlencode(query)
request = urllib2.Request(url, encoded)
if get_json:
return json.loads(urllib2.urlopen(request).read())
return urllib2.urlopen(request).read()