2012-04-13 3 views
0

https에서 HTML 소스 코드를 가져 오는 방법은 무엇입니까? 내가 대신 get_file_contestscurl을 사용하려고 만, 여전히 image srchttps에서 html 소스 코드를 가져 오는 PHP

require dirname(__FILE__) . '/simple_html_dom.php'; 

$curl_handle=curl_init(); 
curl_setopt($curl_handle, CURLOPT_URL,'https://www.tumblr.com/'); 
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($curl_handle, CURLOPT_BINARYTRANSFER, true); 
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($curl_handle, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1"); 
$query = curl_exec($curl_handle); 
curl_close($curl_handle); 

$html = file_get_html($query); 
foreach($html->find('img') as $element) { 
    echo $element->src.'<br />'; 
} 
+0

'file_get_html()'은 (는) PHP의 함수가 아닙니다. itr은 ['file_get_contents()'] 일 수 있습니다. (http://php.net/manual/en/function.file-get-contents.php) – diEcho

+0

@dicho file_get_html()은 simple_html_dom 라이브러리에서 가져옵니다. – ADW

답변

1

변경

$html = file_get_html($query); 

을하지 :

$html = str_get_html($query); 

가 file_get_html 기능은 파일을 기대 (또는 URL을) 변수가 아닙니다.

+0

. 맞습니다. –

관련 문제