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.

try: 
  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)
urllib2.install_opener(opener)

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

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

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.

Thanks

Recommended Answers

All 3 Replies

Any Help Please ?

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

import urllib2

proxy_handler = urllib2.ProxyHandler({'http':'184.73.131.27:3128'})
opener = urllib2.build_opener(proxy_handler)
f = opener.open('http://www.whatismyipaddress.com')
print f.read()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.