dongzhang0243 2013-06-21 06:50
浏览 39
已采纳

如何获得Vine视频标题/描述?

Here is a vine video example https://vine.co/v/bjHh0zHdgZT. How can I get only it's description?

Let's say I have id of the video which is bjHh0zHdgZT and I need to get vine's description for my PHP based website.

Thanks.

  • 写回答

1条回答 默认 最新

  • dpca31461 2013-06-21 10:56
    关注

    Maybe you can parse the meta tag of the page ?

    Source of vine page :

    <meta property="twitter:card" content="player">
    <meta property="twitter:title" content="Jethro Ames's post on Vine">
    <meta property="twitter:description" content="SquareVine 1 #howto #favthings #loop">
    

    To get the description from php with file_get_contents and preg_match :

    <?php
        $url = "https://vine.co/v/bjHh0zHdgZT";
        $data = file_get_contents($url);
        preg_match('~<\s*meta\s+property="(twitter:description)"\s+content="([^"]*)~i', $data, $matches);
        print_r($matches);
        if ( isset($matches[2]) ) {
           $description = $matches[2];
        }
    ?>
    

    Output :

    Array
    (
     [0] => <meta property="twitter:description" content="SquareVine 1 #howto #favthings #loop
     [1] => twitter:description
     [2] => SquareVine 1 #howto #favthings #loop
    )
    

    Your description is $matches[2]. Be careful to control this content (html entities, sql escape, etc.)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?