[英]Getting 'picture' from post using facepy
After getting posts from a group using the facepy package I noticed that some picture are being retrieved whilst others are not. 在使用facepy软件包从小组中获取帖子后,我注意到正在检索某些图片,而另一些则没有。 I am aware that some posts do not have any pictures attached but I have found others which do not have a 'picture' key entry in the data dict yet when I open the post in my browser I can see that there are in fact images attached to the post.
我知道有些帖子没有附加图片,但是我发现其他一些在数据字典中没有“图片”键条目,但是当我在浏览器中打开帖子时,我可以看到实际上附有图片到职位。 This is the code that I am using.
这是我正在使用的代码。
from facepy import GraphAPI
ACCESS_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
graph = GraphAPI(ACCESS_TOKEN)
groupIDs = (['xxxxxxxxxxxxxxx'])
groupData = graph.get(groupIDs[0] + "/feed", page=False, retry=3, limit=600)
dataDict = groupData['data']
for data in dataDict:
try:
picture = property['picture']
except Exception as e:
#no picture available
continue
Any idea of how to get these images? 关于如何获取这些图像的任何想法吗?
UPD: In any case you receive data from a json
. UPD:无论如何,您都从
json
接收数据。 Try this: 尝试这个:
graph = GraphAPI(access_token)
group_id = "xxxxxxxxxxxxxxx"
graph.fql( SELECT post_id, message, attachment FROM stream WHERE source_id=group_id)
This query returns the following data, where fullsize_src
is the link to the picture: 该查询返回以下数据,其中
fullsize_src
是图片的链接:
{
"data": [
{
"message": "test...",
"post_id": "348119228599690_933534210058186",
"updated_time": 1453685624,
"attachment": {
"media": [
{
"href": "http://zakarpattya.net.ua/News/150883-V-Uzhhorodi-vidkryvsia-suchasnyi-Zakarpatskyi-TSentr-Zoru-FOTO",
"alt": "test…",
"src": "https://external.xx.fbcdn.net/safe_image.php?d=AQBHiLIIZmJx9TcO&w=130&h=130&url=http%3A%2F%2Fzakarpattya.net.ua%2Fpostimages%2Fpub%2F2016%2F01%2F530a82085993ba504fea316c82f1f1d609414bd8f744cc8b517dc8507e388164.jpg&cfs=1",
"fullsize_src": "https://external.xx.fbcdn.net/safe_image.php?d=AQBPhLO5Dzhycx5M&w=720&h=720&url=http%3A%2F%2Fzakarpattya.net.ua%2Fpostimages%2Fpub%2F2016%2F01%2F530a82085993ba504fea316c82f1f1d609414bd8f744cc8b517dc8507e388164.jpg&cfs=1",
"type": "link"
}
],
"name": "test",
"href": "http://l.facebook.com/l.php?u=http%3A%2F%2Fzakarpattya.net.ua%2FNews%2F150883-V-Uzhhorodi-vidkryvsia-suchasnyi-Zakarpatskyi-TSentr-Zoru-FOTO&h=lAQF-JR_g&s=1",
"caption": "zakarpattya.net.ua",
"description": "test…",
}
},
. . .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.