Created
July 29, 2012 14:58
-
-
Save justquick/3199384 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import gdata.spreadsheet.service | |
import requests | |
import sys | |
client = gdata.spreadsheet.service.SpreadsheetsService() | |
client.email = '[email protected]' | |
client.password = 'XXX' | |
client.source = 'Example Spreadsheet Writing Application' | |
client.ProgrammaticLogin() | |
spreadsheet_key = '0AoUGp7rVrlk3dGdFZ1pITXlocDQyX1VZa3EwV09xU3c' | |
worksheet_id = 'od6' | |
yp_url = 'http://api2.yp.com/listings/v1/search' | |
params = { | |
'term': 'bar', | |
'searchloc': 'baltimore', | |
'sort': 'distance', | |
'radius': '.5', | |
'format': 'json', | |
'key': '78443ad9090000a987a27148bd4960f0', | |
} | |
from pprint import pprint | |
response = requests.get(yp_url, params=params) | |
for result in response.json['searchResult']['searchListings']['searchListing']: | |
row = { | |
'name': result['businessName'], | |
'phone': result['phone'] | |
} | |
entry = client.InsertRow(row, spreadsheet_key) | |
if isinstance(entry, gdata.spreadsheet.SpreadsheetsList): | |
print "Insert row succeeded." | |
else: | |
print "Insert row failed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment