发布于 2016-01-17 09:28:48 | 217 次阅读 | 评论: 0 | 来源: PHPERZ
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://www.baidu.com/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
$str = curl_exec($curl);
curl_close($curl);
$html= str_get_html($str);
...
// 定义 HTTP 头信息.
$context = array
(
'http' => array
(
'proxy' => 'addresseproxy:portproxy', // 这里设置具体的代理服务器的ip和端口
'request_fulluri' => true,
),
);
$context = stream_context_create($context);
$html= file_get_html('http://www.php.net', false, $context);
...
$html = file_get_html(...);
// do something...
$html->clear();
unset($html);