oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.
如果网站支持oEmbed,那么这比抓取HTML更简单、更健壮:
oEmbed受到YouTube和Flickr等网站的支持。
使用类似cURL的内容获取页面,然后使用类似Simple HTML DOM的内容解析页面并提取所需的元素。
Embed.ly有一个很好的api用于这个目的。他们的api返回站点的oEmbed数据(如果可用的话),否则,它会试图像Facebook一样提取页面的摘要。
相关问题 更多 >
编程相关推荐