In Python 3, we need to specify encoding when open a fileįacebookScraper class to scrape facebook info Reloading sys for utf8 encoding is for Python 2.7 CocaCola), Json File Name, Feed csv file path, Likes csv file path, Comments csv file path, Since data (from when to pull the data). It takes 7 argumenst: Access Token, Page Name (e.g. Then, we convert the response to a JOSN object for further processing. To make a GET request, we can simply add url and access token as a parameter in the get() function. In my opinion, the requests package is the best thing happened for creating REST applications with Python. However, I am using the requests and json packages to make API calls and process data. Python has Facebook SDK and it works fine. Get App ID and App Secret From the dashboard.Enter Display Name and hit ‘Create App ID’.Select ‘Add New App’ from the top left corner.We can use this neat trick to create access token by concatenating App ID and App Secret with “|”.įirst of all, we need to create an app and generate API credentials. In this example, all we need is App ID and App Secret. Likes and Comments can be joined to Feed by the Page_Name and Post_Id.įacebook offers different methods for authentication depending on which API function you want to use. In the Feed table, Page_Name and Id are the composite keys. This data model nicely accommodates the one-to-many relationship. Each post has one or many likes and comments. Once the data is in the tabular format, we can load it in the relational database or use common analytical tools (like Excel) to do further analysis. I have written a python script to scrape the feed info in the JSON format and turn it into structured tables. By using Facebook Graph API, we can get the feed of posts and links published by the specific page, or by others on this page as well as likes and comments ( feed api).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |