Wednesday 2 October 2013

Why I can't get complete data from using Google Map api?

Why I can't get complete data from using Google Map api?

I created a Python project to test google map api. I occured problem when
I test the first API:Nearby Search Requests.
I tried this url official doc provided:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AddYourOwnKeyHere
if I put this url on my browser,I'll get perfect data on browser. Then I
did nothing but created a python module , here is the code :
if __name__ == '__main__':
import socket
import ssl
sock = ssl.wrap_socket(socket.socket())
sock.connect(('maps.googleapis.com', 443))
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('maps.googleapis.com', 443))
sslSocket = socket.ssl(s)
uri = 'GET
/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&sensor=false&key=MyKey
HTTP/1.1\r\nHost:maps.googleapis.com\r\nContent-Type: application/json;
charset=UTF-8\r\naccept-encoding:gzip,deflate,sdch\r\n\r\n'
sslSocket.write(uri)
data = sock.read()
print 'going to connect...'
print data
s.close()
UnfortunatelyCthe result on the console I got is like this F
going to connect...
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Date: Wed, 02 Oct 2013 08:05:59 GMT
Expires: Wed, 02 Oct 2013 08:10:59 GMT
Cache-Control: public, max-age=300
Vary: Accept-Language
Server: mafe
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Alternate-Protocol: 443:quic
Transfer-Encoding: chunked
560b
{
"debug_info" : [],
"html_attributions" : [
"Listings by \u003ca href=\"http://www.yellowpages.com.au/\"\u003eYellow
Pages\u003c/a\u003e"],
"next_page_token" :
"ClRHAAAA4lOaMlZcUjyndIqhBsHzyyU0nD5PHarmjgmnguj3morn7Em-
ipqhSR33V__d0kjrL4PzAqY7y4TAK7Uj3XzWjhoUchLBcBs-
TNFxWIvGst8SEArmj_T7_eDZWyr8UDGy5OEaFPFaK2yHDg7Kv2U3Obsy7opkQfEw",
"results" : [
{
"geometry" : {
"location" : {
"lat" : -33.8599827,
"lng" : 151.2021282
},
"viewport" : {
"northeast" : {
"lat" : -33.8552584,
"lng" : 151.2031401
},
this result is incomplete and I tried many times, the results are same.
So, how to solve this problem?

No comments:

Post a Comment