Python Script: Export a list of Facebook Fans for a Page to CSV
I made a primitive script to export a list of Facebook fans for a Page.
It's somewhat cumbersome to use, as you need to hand it some HTTP headers such as your cookie. Instructions are in the script. If someone has an easier way of doing this, please let me know :-)
The files open nicely in Numbers on Mac, nothing else is tested.
Thanks to Adam Loving for the inspiration and original codebase.


I updated the header information in the python script and when I try to run it, I get this error:
[root@gold httpdocs]# python facebookfans.py <pageid> fans.csv
In page 0
Traceback (most recent call last):
File "facebookfans.py", line 167, in ?
fans_list = fetch_fans(sys.argv[1])
File "facebookfans.py", line 70, in fetch_fans
li = [k for k in fans['payload']['user_info']]
TypeError: unsubscriptable object
In page 0
Traceback (most recent call last):
File "facebookfans.py", line 167, in ?
fans_list = fetch_fans(sys.argv[1])
File "facebookfans.py", line 67, in fetch_fans
page = get_page(page_count, page_id)
File "facebookfans.py", line 49, in get_page
response = urllib2.urlopen(req)
File "/usr/lib64/python2.4/urllib2.py", line 130, in urlopen
return _opener.open(url, data)
File "/usr/lib64/python2.4/urllib2.py", line 358, in open
response = self._open(req, data)
File "/usr/lib64/python2.4/urllib2.py", line 376, in _open
'_open', req)
File "/usr/lib64/python2.4/urllib2.py", line 337, in _call_chain
result = func(*args)
File "/usr/lib64/python2.4/urllib2.py", line 1032, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib64/python2.4/urllib2.py", line 1004, in do_open
r = h.getresponse()
File "/usr/lib64/python2.4/httplib.py", line 872, in getresponse
response.begin()
File "/usr/lib64/python2.4/httplib.py", line 336, in begin
version, status, reason = self._read_status()
File "/usr/lib64/python2.4/httplib.py", line 300, in _read_status
raise BadStatusLine(line)
httplib.BadStatusLine
Can I pay you to do this for me?
john.wayne.zimmerman @ gmail dot com
Thanks.
Thanks for the feedback. Sorry I haven't been able to update the script. I'm guessing FB has changed things around a bit. I don't have time to fix it at the moment, unfortunately :(
John: I might be able to help you – you could send me an email at chris@ctolsen.no if you're still interested.
i am a major noob... but i am from a marketing company that overseas 5 facebook fan pages that total over 250,000 fans.
can i pay you to extract these to csv./excel file...??
my email is humilityclothing@hotmail.com
let me know asap,
cheers,
Jim
http://www.vcgs.net/blog/2011/05/06/admin/admin/export-fans-from-your-faceboo...
Regards
A new version of fbPageMembers includes Magic Importer to automatically import the fans.
Please, take a tour to http://www.fbpagemembers.com/ and read the documentation to know how fbPageMembers works....
Thanks!
Get Fans on Facebook