Ai
1 Star 0 Fork 1

jack2583/PythonExamples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
get_likes_on_FB.py 844 Bytes
一键复制 编辑 原始数据 按行查看 历史
Jérôme Krell 提交于 2019-10-10 20:22 +08:00 . Reformat Code by PyCharm-Community
from __future__ import print_function
import json
import sys
import urllib
accessToken = 'TOKENVALUE' # YOUR ACCESS TOKEN GETS INSERTED HERE
userId = sys.argv[1] # USERID
limit = 100
url = 'https://graph.facebook.com/' + userId + '/posts?access_token=' + accessToken + '&limit=' + str(limit) # FB Link
data = json.load(urllib.urlopen(url))
id = 0
print(str(id))
for item in data['data']:
time = item['created_time'][11:19]
date = item['created_time'][5:10]
year = item['created_time'][0:4]
if 'shares' in item:
num_share = item['shares']['count']
else:
num_share = 0
if 'likes' in item:
num_like = item['likes']['count']
else:
num_like = 0
id += 1
print(str(id) + '\t' + time.encode('utf-8') + '\t' + date.encode('utf-8') + '\t' + year.encode('utf-8') + '\t' + str(
num_share) + '\t' + str(num_like))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jack2583/pythonExamples.git
git@gitee.com:jack2583/pythonExamples.git
jack2583
pythonExamples
PythonExamples
master

搜索帮助