On Sat, Mar 2, 2013 at 7:59 PM, Cloga <clog...@gmail.com> wrote:
> Hi all:
> I need use proxy to request Google's services , how I use http proxy with
> Google API Python Client.I am a fresh man in python.Could some one give me
> some sample code?Many thanks.
> PS:When I use Google API Python Client without proxy , I will get a Errno
> 10060 of httplib2.
You setup the proxy information when you create the httplib2 object:
http://httplib2.googlecode.com/hg/doc/html/libhttplib2.html#httplib2.Http
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google API Python Client" group.
> To unsubscribe from this group and stop receiving emails from it, send an
Any clue of fixing?
Here are the codes:
p = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, proxy_host="proxy without http://", proxy_port='port no', proxy_user=proxyuser, proxy_pass = proxypassword)
theHttp = httplib2.Http(proxy_info = p)
searchCnter = qGenerator(individual.rstrip(),entity.rstrip(),keyword.rstrip(),searchCnter,theHttp)
....function qGenerator passes theHttp to function gSearch
...function gSearch passes theHttp to build
service = build("customsearch", "v1", developerKey="[dev key]", http=theHttp)
...
res = service.cse().list( q= qName, cx='cx code here', #lr = lang_en, num = 10, ).execute()
...
Here are the error messages:
C:\Users\xxxxx\workspace\Google>python KYCSearch_v0.2.py
build() takes at most 2 positional arguments (3 given)
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\httplib2-0.9.2-py3.3.egg\httplib2\__init__.py", line 986, in _conn_request
conn.connect()
File "C:\Python33\lib\http\client.py", line 1194, in connect
self.timeout, self.source_address)
File "C:\Python33\lib\socket.py", line 417, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11004] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "KYCSearch_v0.2.py", line 208, in <module>
main()
File "KYCSearch_v0.2.py", line 198, in main
searchCnter = qGenerator(individual.rstrip(),'','',searchCnter,theHttp)
File "KYCSearch_v0.2.py", line 171, in qGenerator
gSearch(qName_Keywords,str(searchCnter),theHttp)
File "KYCSearch_v0.2.py", line 102, in gSearch
http=theHttp)
File "C:\Python33\lib\site-packages\oauth2client-1.5.0-py3.3.egg\oauth2client\util.py", line 142, in positional_wrapper
File "C:\Python33\lib\site-packages\google_api_python_client-1.4.2-py3.3.egg\googleapiclient\discovery.py", line 196, in build
File "C:\Python33\lib\site-packages\google_api_python_client-1.4.2-py3.3.egg\googleapiclient\discovery.py", line 242, in _retrieve_discovery_doc
File "C:\Python33\lib\site-packages\httplib2-0.9.2-py3.3.egg\httplib2\__init__.py", line 1313, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "C:\Python33\lib\site-packages\httplib2-0.9.2-py3.3.egg\httplib2\__init__.py", line 1063, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "C:\Python33\lib\site-packages\httplib2-0.9.2-py3.3.egg\httplib2\__init__.py", line 993, in _conn_request
raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
httplib2.ServerNotFoundError: Unable to find the server at www.googleapis.com