- Python Social Media Analytics
- Siddhartha Chatterjee Michal Krystyanczuk
- 132字
- 2021-07-15 17:24:58
Connect to the API
The following are the steps to connect to the API:
- Firstly, we import the required libraries as follows:
import requests import json
- Create a params variable that contains your access token.
params = {'access_token': 'YOUR_ACCESS_TOKEN'}
- Make a request to the feed for the Mercedes Benz page.
page_url = 'https://graph.facebook.com/v2.8/MercedesBenzFrance/feed' result = requests.get(page_url, params = params)
- Parse the results as a JSON.
data = result.json()
The data field contains a list of messages with the following fields: message, created_at, and id. We will print the content of messages.
for element in data['data']: print(element['message']
This simple method helps us access the content of conversations on Facebook pages. We will use this information to perform data mining and extract insights in Chapter 3, Uncovering Brand Activity, Emotions, and Popularity on Facebook.
推薦閱讀
- Web Application Development with R Using Shiny(Second Edition)
- PHP網(wǎng)絡(luò)編程學(xué)習(xí)筆記
- 面向?qū)ο蟪绦蛟O(shè)計(Java版)
- Ext JS 4 Web Application Development Cookbook
- SQL Server 2016數(shù)據(jù)庫應(yīng)用與開發(fā)
- Internet of Things with ESP8266
- Developing SSRS Reports for Dynamics AX
- MySQL程序員面試筆試寶典
- Mastering Docker
- Xamarin Blueprints
- Android Studio Cookbook
- 網(wǎng)絡(luò)數(shù)據(jù)采集技術(shù):Java網(wǎng)絡(luò)爬蟲實戰(zhàn)
- SFML Game Development
- LabVIEW入門與實戰(zhàn)開發(fā)100例(第4版)
- ANSYS FLUENT 16.0超級學(xué)習(xí)手冊