如何从网址获取信息

时间:2019-09-28 12:07:18

标签: php linkedin telegram

是否可以通过链接(标题,字幕,详细信息,图片)获取链接信息?

就像电报和LinkedIn中的电报一样,当您将一些链接发布或发送到频道或群组时,您可以看到该链接的一些细节。

如何针对php代码执行此操作?

1 个答案:

答案 0 :(得分:0)

获取有关该链接的信息的唯一方法是对页面进行爬网,然后从标题中的特殊元标记(<meta property="og:...")中提取数据,然后进行相应显示。也许您需要一个可以完成此任务的现成软件包,甚至使用jQuery,您也应该能够对其进行解析。以下是在当前页面上生成的标记的示例:

    <meta property="og:type" content="website">
    <meta property="og:url" content="https://stackoverflow.com/questions/58146161/ability-to-get-article-link-information/58146431">
    <meta property="og:site_name" content="Stack Overflow">
    <meta property="og:image" itemprop="image primaryImageOfPage" content="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon@2.png?v=73d79a89bded">

    <meta name="twitter:card" content="summary">
    <meta name="twitter:domain" content="stackoverflow.com">
    <meta name="twitter:title" property="og:title" itemprop="name" content="Ability to get article link information">
    <meta name="twitter:description" property="og:description" itemprop="description" content="The only way to get information about that link is to crawl the page and then extract the data from special meta tags (&amp;lt;meta property=&quot;og:...&quot;) in the header, then display it accordingly.  Perha...">

    <meta name="twitter:app:country" content="US">
    <meta name="twitter:app:name:iphone" content="Stack Exchange iOS">
    <meta name="twitter:app:id:iphone" content="871299723">
    <meta name="twitter:app:url:iphone" content="se-zaphod://stackoverflow.com/questions/58146161/ability-to-get-article-link-information/58146431">
    <meta name="twitter:app:name:ipad" content="Stack Exchange iOS">
    <meta name="twitter:app:id:ipad" content="871299723">
    <meta name="twitter:app:url:ipad" content="se-zaphod://stackoverflow.com/questions/58146161/ability-to-get-article-link-information/58146431">
    <meta name="twitter:app:name:googleplay" content="Stack Exchange Android">
    <meta name="twitter:app:url:googleplay" content="http://stackoverflow.com/questions/58146161/ability-to-get-article-link-information/58146431">
    <meta name="twitter:app:id:googleplay" content="com.stackexchange.marvin">