I am trying to work on some code for updating google docs using the python gdata api's.

The code works perfectly fine when i try to run the code in a cafe internet or home network without my proxy. When i have to deploy the code in my workplace - it would never work because of the proxy. I understand i have to use urllib2. I tried all different combination's but still no luck.

This is a simple python code that i am using to get all the name of the sheets on a particular account.

  from xml.etree import ElementTree
except ImportError:  
  from elementtree import ElementTree
import gdata.spreadsheet.service
import gdata.service
import atom.service
import gdata.spreadsheet
import atom
import gdata.docs.service
import urllib2, urllib

proxy = urllib2.ProxyHandler({'http': 'http://myproxy:3000'})
auth = urllib2.HTTPBasicAuthHandler()
opener = urllib2.build_opener(proxy)

client = gdata.spreadsheet.service.SpreadsheetsService()
client.email = ''
client.password = ''

feed = client.GetDocumentListFeed()
for entry in feed.entry:

1. What am i doing wrong in specifying the proxy that it should use ? (How can i specify so that i handle my proxy correctly)
2. Is there a mechanism by which i can autodetect the proxy without having to mention it in my code.


6 Years
Discussion Span
Last Post by ravigup

Here is a proxy test that worked for me.
Maybe it can help you.

import urllib2

proxy_handler = urllib2.ProxyHandler({'http':''})
opener = urllib2.build_opener(proxy_handler)
f = opener.open('http://www.whatismyipaddress.com')
print f.read()

Edited by snippsat: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.