2013-12-17 2 views
0
<?php 
    $html = file_get_contents('http://xpool.xram.co/index.cgi'); 
    echo $html; 
?> 

PHP를 사용하여 원격 웹 사이트의 태그에 정보를 얻고 싶습니다. 태그 만PHP를 사용하여 원격 사이트에서 특정 태그 얻기

이 작은 문자열은 전체 사이트 소스를 검색하는 데 유용합니다. 그러나, 나는 단지 작은 섹션을 얻고 싶다. 다른 태그를 모두 제외하고 필요한 태그 하나만 얻으려면 어떻게합니까?

+2

http://stackoverflow.com/questions/960841/how-to-use-dom-php-parser –

답변

1

PHP DOM 파서를 사용하는 것이 좋습니다.

require_once ('simple_html_dom.php'); 

$html = file_get_contents('http://xpool.xram.co/index.cgi'); 

$p = $html->find('p'); // Find all p tags. 

$specific_class = $html->find('.classname'); // Find elements with classname as class. 

$element_id = $html->find('#element'); // Find element with the id element 

(http://simplehtmldom.sourceforge.net/manual.htm)

는 다른 옵션의 톤을 사용할 수가의 문서를 참조하십시오.

관련 문제