- 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.
推薦閱讀
- 大學計算機應用基礎實踐教程
- Arduino開發實戰指南:LabVIEW卷
- Mastering LibGDX Game Development
- Mastering Yii
- Python Web數據分析可視化:基于Django框架的開發實戰
- Spring Boot+Vue全棧開發實戰
- 軟件測試綜合技術
- IDA Pro權威指南(第2版)
- Learning Splunk Web Framework
- 零基礎輕松學C++:青少年趣味編程(全彩版)
- 百萬在線:大型游戲服務端開發
- Google Adsense優化實戰
- Building Clouds with Windows Azure Pack
- Unity虛擬現實開發圣典
- Web程序設計與架構