好的更新了一切。我用这个函数:
private function get_follow_url($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$a = curl_exec($ch);
if(preg_match('Location:(.*)', $a, $r)){
$url=trim($r[1]);
$this->get_follow_url($url);
}
return $a;
}
当它被回应时,我得到了这个:
HTTP/1.1 301 Moved Permanently Server: nginx/0.7.67 Date: Sun, 14 Oct 2012 10:03:21 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive X-Powered-By: PHP/5.2.17 X-Pingback: http://thesexguy.com/xmlrpc.php Location: http://example.com/mature Content-Length: 0
所以我做了一个递归..并且在抓取位置字后尝试再次获取页面...
在递归时我应该http://example.com/mature吗?我对吗?但是我没有抓住位置词......为什么?