Skip to content

Instantly share code, notes, and snippets.

@justquick
Created July 29, 2012 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justquick/3199384 to your computer and use it in GitHub Desktop.
Save justquick/3199384 to your computer and use it in GitHub Desktop.
import time
import gdata.spreadsheet.service
import requests
import sys
client = gdata.spreadsheet.service.SpreadsheetsService()
client.email = 'XXX@gmail.com'
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