我想要提取此网址的内容: http://www.freeproxylists.net/?s=rs
我使用了这段代码:
<?php
$url = str_replace(' ', '%20', "http://www.freeproxylists.net/?s=rs");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36');
//curl_setopt( $ch, CURLOPT_COOKIE, $action['cockie'] );
$data['content'] = curl_exec($ch);
$data['rescode'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$data['type'] = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
$data['endurl'] = urldecode ( curl_getinfo($ch, CURLINFO_EFFECTIVE_URL) );
curl_close($ch);
echo $data['content'];
?>
当我使用浏览器打开这个网址时,它会显示主要内容,但是使用php curl给我一个带验证码的页面。
我也通过套接字发送了浏览器发送给url的所有标头。但这次它给了我一个带验证码的页面。但为什么??