Created
February 7, 2012 08:16
-
-
Save ismaild/1758208 to your computer and use it in GitHub Desktop.
Search Facebook Graph API for specific string and write to CSV
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
fbsearch.py | |
[email protected] | |
""" | |
import facepy | |
import csv | |
fieldnames = [u'category', u'name', u'id'] | |
sstring = 'recipes' | |
stype = 'page' | |
f = open(sstring + '.csv','w') | |
writer = csv.DictWriter(f, fieldnames) | |
graph = facepy.GraphAPI() | |
z = graph.search(sstring,stype,page=True) | |
for col in z: | |
for rec in col['data']: | |
for item in rec: | |
rec[item] = rec[item].encode('ascii', 'ignore') | |
writer.writerow(rec) | |
print rec | |
print "writing...." | |
print "All done" | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment