2014-01-16 3 views

답변

0

에 네, 실제로 가능하다 가고 DOMDocumentDOMXPath

// if the below line does not work, you will need to use CURL or similar. 
$theHtmlToParse = file_get_contents('http://url.to/page.html'); 
$doc = new DOMDocument(); 
$doc->loadHTMLFile($theHtmlToParse); 
$xpath = new DOMXpath($doc); 
$elements = $xpath->query("*/div[@class='bio']/div[@class='value']"); 
// We now have an array of elements, or null 
if ($elements !== null) 
{ 
    foreach ($elements as $element) 
    { 
     echo "<br/>[". $element->nodeName. "]"; 

     $nodes = $element->childNodes; 
     foreach ($nodes as $node) 
     { 
      echo $node->nodeValue. "\n"; 
     } 
    } 
} 

이 충분히 당신을 주어야한다 사용하는 것이 좋습니다.

. 및 Guzzle의 내용을 얻으려면 visionmedia/php-selector과 같은 것을 사용하거나, 소스를 가져 오기 전에 몇 가지 컬을 사용하십시오.

0

음, 이것은 file_get_contents() 기능을 사용하여 수행 할 수 있습니다. 웹 페이지의 urlfunction에 입력 한 다음 object을 작성하기 만하면됩니다. 필요에 따라 ->을 사용하여 개체를 탐색합니다.