2013-06-21 4 views

답변

1

아마도 페이지의 메타 태그를 구문 분석 할 수 있습니까? 포도 나무 페이지의

출처 :

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

는 file_get_contents와는 preg_match와 PHP의 설명을 취득하려면 : 출력

<?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]; 
    } 
?> 

:

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

귀하의 설명을 $ 일치 [2 ]. 이 콘텐츠 (HTML 엔티티, SQL 이스케이프 등)를 제어하는 ​​데주의하십시오. 감사합니다. 대단히 고마워요!

+0

그건 완벽하게 작동합니다! –

관련 문제