2012-06-06 4 views
0

웹 페이지의 일부 콘텐츠를 컬 및 simple_html_DOM을 사용하여 표시하려고합니다. 콘텐츠를 표시 할 때마다 html 콘텐츠를 실제로 표시하는 방법을 배열로 나타냅니다.simple_html_DOM을 사용하여 웹 페이지에서 div를 표시합니다.

<?php 
echo ("hello"); 

include 'simple_html_dom.php'; 

$curl = curl_init(); 
curl_setopt ($curl, CURLOPT_URL, "http://catalog.hastingsfilter.com/startautoapps.html"); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); 
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt($curl, CURLOPT_REFERER, "http://catalog.hastingsfilter.com/startautoapps.html"); 

$result = curl_exec ($curl); 
curl_close ($curl); 
//write contents of $result to file 
$File = "page.txt"; 
$fh = fopen($File, 'w') or die("can't open file"); 
fwrite($fh, $result); 
fclose($fh); 
//turn file into dom object 
$page = file_get_html("page.txt"); 
$div = $page->find('div[id=columnright]'); 
echo $div; 

?> 

덕분에

답변

1

iframe>이 쿼리를 망치고있는 것 같습니다. 내부 <입니다. 임 확실하지 왜 간단한 HTML DOM 그런 행동 .. 이유에 쿼리를 변경하지 않는 :

$div = $page->find("iframe[name='main2']"); 
echo $div[0]->innertext; 

편집 :

이 같은 하려면 .src 속성을 변경할 수 있습니다

$page = file_get_html("page.txt"); 
... 
$page->find("iframe[name='main2']",0)->src = "foo"; 
$thehtml = $page->save(); 

나는 직접 <라고 부릅니다. iframe> 소스와 또한 노 서버를 찾았습니다.

+0

그래도 outterext를 사용하여 표시 할 수있게되었지만 iframe 내부에서 만드는 호출은 다음과 같습니다. 내 URL을 사용하는 대신 사이트에서 정보를 얻으려고 내가 얻을 수있는 모든 것입니다 페이지는 서버 메시지에서 찾을 수 없습니다 – arrowill12

+0

내가 예를 들어 변수를 에코하기 전에 속성을 변경하는 방법은 iframe에 src 변경? – arrowill12

+0

수정 된 게시물 확인 –

0

잘 모르겠어요,하지만 난 당신이 사업부의 내용을 얻을 수

$div->innertext; 

을 사용해야 할 수도 있습니다 생각합니다.

+0

단어 배열을 없애 버렸습니다. – arrowill12

관련 문제