1

在使用 facepy 包从一个组中获取帖子后,我注意到一些图片正在被检索,而另一些则没有。我知道有些帖子没有附加任何图片,但我发现其他帖子在数据字典中没有“图片”键条目,但是当我在浏览器中打开帖子时,我可以看到实际上附加了图像到帖子。这是我正在使用的代码。

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

知道如何获取这些图像吗?

4

1 回答 1

0

UPD:无论如何,您都会从json. 尝试这个:

graph = GraphAPI(access_token)
group_id = "xxxxxxxxxxxxxxx"
graph.fql( SELECT post_id, message, attachment FROM stream WHERE source_id=group_id)

此查询返回以下数据,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…",

      }
    },
  . . .
于 2016-01-24T16:16:37.207 回答