这是stackoverflow.com的og:图像元标记:
<meta property="og:image" itemprop="image primaryImageOfPage" content="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon@2.png?v=ea71a5211a91&a" />
是否可以通过Facebook的Open Graph API读取此信息,而不是手动抓取页面?
https://graph.facebook.com/?id=http://stackoveflow.com返回:
{
"og_object": {
"id": "10150180465825637",
"description": "Q&A for professional and enthusiast programmers",
"title": "Stack Overflow",
"type": "website",
"updated_time": "2015-07-21T12:33:38+0000",
"url": "http://stackoverflow.com/"
},
"share": {
"comment_count": 4,
"share_count": 32367
},
"id": "http://stackoverflow.com"
}
答案 0 :(得分:0)
如果您另外请求picture
字段,则应获得所需的结果:
/?id=http://stackoverflow.com&fields=id,share,og_object{id,title,type,updated_time,url,picture}
返回
{
"id": "http://stackoverflow.com",
"share": {
"comment_count": 4,
"share_count": 32367
},
"og_object": {
"id": "10150180465825637",
"title": "Stack Overflow",
"type": "website",
"updated_time": "2015-07-21T12:33:38+0000",
"url": "http://stackoverflow.com/",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQA6I9bpNGiU11fN&w=200&h=200&url=http%3A%2F%2Fcdn.sstatic.net%2Fstackoverflow%2Fimg%2Fapple-touch-icon%402.png%3Fv%3Dea71a5211a91%26a&crop"
}
}
}
}