Skip to content

Instantly share code, notes, and snippets.

@psychemedia
Created April 10, 2012 14:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save psychemedia/2351614 to your computer and use it in GitHub Desktop.
Save psychemedia/2351614 to your computer and use it in GitHub Desktop.
Yahoo Pipes - Published pipes exporter, by User ID
# Simple exporter for published Yahoo Pipes
# For use with (glue still required!) pipe2py - https://github.com/ggaughan/pipe2py
uid='' #Your Yahoo Pipes ID
#-------
import simplejson,urllib,csv
def getPipesPage(uid,pageNum):
print 'getting',uid,pageNum
pipesFeed='http://pipes.yahoo.com/pipes/person.info?_out=json&display=pipes&guid='+uid+'&page='+str(pageNum)
feed=simplejson.load(urllib.urlopen(pipesFeed))
return feed
def getPipesData(id):
srcURL='http://pipes.yahoo.com/pipes/pipe.info?_out=json&_id='+id
srcf = urllib.urlopen(srcURL)
return srcf.read()
page=1
scrapeit=True
f=open('pipesExport_'+uid+'.csv','wb+')
writer=csv.writer(f)
while (scrapeit):
feeds= getPipesPage(uid,page)
print feeds
if feeds['value']['hits']==0:
f.close()
scrapeit=False
else:
for pipe in feeds['value']['items']:
id=pipe['id']
src=getPipesData(id)
writer.writerow([pipe['description'],pipe['title'],src])
page=page+1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment