[英]display photo or video from a link
是否有某种插件可以显示网站链接中的照片或视频,例如,如果您在Facebook上发布链接,它会加载链接的微缩图片?
This is called URL Scraping. 这称为URL Scraping。 What you would need to do is load the URL and look at the content of the HTML that is returned. 您需要做的是加载URL并查看返回的HTML的内容。 From that the scraper would decide what images, and information are best suited for a "preview". 由此刮刀将决定哪些图像和信息最适合“预览”。
Usually scrapers would look at the pages meta data embedded within <meta>
tags. 通常,scraper会查看<meta>
标记中嵌入的页面元数据。
A great example (and how Facebook does it) is the Open Graph protocol. 一个很好的例子(以及Facebook如何做到这一点)是Open Graph协议。 You can read more about it here - http://ogp.me/ 你可以在这里阅读更多相关信息 - http://ogp.me/
Here is an example of what Open Graph meta tags look like - 以下是Open Graph元标记的示例 -
<meta property="og:title" content="The Rock"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
<meta property="og:site_name" content="IMDb"/>
<meta property="fb:admins" content="USER_ID"/>
<meta property="og:description"
content="A group of U.S. Marines, under command of
a renegade general, take over Alcatraz and
threaten San Francisco Bay with biological
weapons."/>
When you post a link on Facebook, it will go out and look for meta tags like these and use their information to display a preview of the link. 当您在Facebook上发布链接时,它会出去查找这些元标记并使用其信息显示链接的预览。
你正在寻找蜘蛛: https : //github.com/mikeal/spider (或类似谷歌的东西),请阅读@lix所说的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.