简体   繁体   中英

display photo or video from a link

是否有某种插件可以显示网站链接中的照片或视频,例如,如果您在Facebook上发布链接,它会加载链接的微缩图片?

This is called URL Scraping. What you would need to do is load the URL and look at the content of the HTML that is returned. 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.

A great example (and how Facebook does it) is the Open Graph protocol. You can read more about it here - http://ogp.me/

Here is an example of what Open Graph meta tags look like -

<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.

你正在寻找蜘蛛: https//github.com/mikeal/spider (或类似谷歌的东西),请阅读@lix所说的内容。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM