0
如何從https獲取html源代碼?我嘗試用curl
代替get_file_contests
,但仍然沒有得到image src
php從https獲取html源代碼
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 />';
}
'file_get_html()'不是php中的函數。 itr可能是['file_get_contents()'](http://php.net/manual/en/function.file-get-contents.php) – diEcho 2012-04-13 08:47:16
@diEcho file_get_html()來自simple_html_dom庫。 – ADW 2012-04-13 08:55:53