Thursday, October 16, 2014

Playing with the Facebook Graph API in Python: Downloading posts from "The Elbi Files" Page

If you are a fan of The Elbi Files, you can download the posts on the page using the procedure described here. I am using Ubuntu 12.04.

  1. Install pip[1].
  2. Configure and activate facebookenv virtual environment[2].
  3. Install requests package while in facebookenv environment: pip install requests
  4. Get an access token using Facebook's Graph API Explorer tool[3].
  5. Download the Python file below. Make sure you change the access token to the  one you obtained from step 4.
  6. Run the script on the terminal and redirect the output to a file:  PYTHONIOENCODING=UTF-8 python > elbifiles.txt
  7. Note that the script downloads the messages only. Facebook however allows you to download more! Use responsibly. Now do some "interesting" text processing on the text file!



neilmarion said...

I'm pretty sure there are Python libraries that automatically generates your fb access token just by giving it, as parameters, your app id and app secret. Rather than copy-pasting from the api explorer. But first create your facebook app ( :P