如何创建类似facebook sh的URL提取器

2024-04-26 13:39:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要从url中提取数据 像标题、描述和给定url中的任何视频图像 喜欢facebook分享按钮

像这样: http://www.facebook.com/sharer.php?u=http://www.wired.com&t=Test

问候


Tags: 数据test图像comhttpurl标题视频
3条回答

如果网站支持oEmbed,那么这比抓取HTML更简单、更健壮:

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受到YouTube和Flickr等网站的支持。

使用类似cURL的内容获取页面,然后使用类似Simple HTML DOM的内容解析页面并提取所需的元素。

Embed.ly有一个很好的api用于这个目的。他们的api返回站点的oEmbed数据(如果可用的话),否则,它会试图像Facebook一样提取页面的摘要。

相关问题 更多 >