1
Jeremial 2015-07-23 16:33:00 +08:00
|
2
feiyuanqiu 2015-07-23 16:37:45 +08:00
卧槽!我在公司啊,给我跳转到草榴去了!
... file_get_contents('http://i.doovoo.biz/1.php'); var_dump($http_response_header);exit; 请求完成之后直接拿头信息就可以得到最终跳转的url了 注意前面几个 302 跳转 array (size=26) 0 => string 'HTTP/1.1 302 Found' (length=18) 1 => string 'Date: Thu, 23 Jul 2015 08:33:26 GMT' (length=35) 2 => string 'Server: Apache' (length=14) 3 => string 'X-Powered-By: PHP/5.5.9-1ubuntu4.4' (length=34) 4 => string 'Set-Cookie: iutobe=yes; expires=Sun, 26-Jul-2015 08:33:26 GMT; Max-Age=259200' (length=77) 5 => string 'Location: http://ad.www.clwaiting.com/so/all.php' (length=48) 6 => string 'Content-Length: 0' (length=17) 7 => string 'Connection: close' (length=17) 8 => string 'Content-Type: text/html' (length=23) 9 => string 'HTTP/1.1 302 Found' (length=18) 10 => string 'Date: Thu, 23 Jul 2015 08:33:26 GMT' (length=35) 11 => string 'Server: Apache/2.2.27 (CentOS)' (length=30) 12 => string 'X-Powered-By: PHP/5.2.17' (length=24) 13 => string 'Set-Cookie: iutobe=yes; expires=Sun, 26-Jul-2015 08:33:26 GMT' (length=61) 14 => string 'Set-Cookie: page=https%3A%2F%2Fwww.caodsma.com%2Ft%2F; expires=Sun, 26-Jul-2015 08:33:26 GMT' (length=92) 15 => string 'Location: https://www.caodsma.com/t/' (length=36) 16 => string 'Content-Length: 0' (length=17) 17 => string 'Connection: close' (length=17) 18 => string 'Content-Type: text/html; charset=UTF-8' (length=38) 19 => string 'HTTP/1.1 200 OK' (length=15) 20 => string 'Server: nginx' (length=13) 21 => string 'Date: Thu, 23 Jul 2015 08:33:28 GMT' (length=35) 22 => string 'Content-Type: text/html' (length=23) 23 => string 'Connection: close' (length=17) 24 => string 'Vary: Accept-Encoding' (length=21) 25 => string 'X-Powered-By: PHP/5.4.41' (length=24) |
3
lissome OP |
4
feiyuanqiu 2015-07-23 17:06:47 +08:00
拿到了,他的服务器稍微检查了下header看是不是爬虫,所以你爬的时候需要带一个header:
$opt = array( 'http' => array( 'method' => 'GET', 'header' => "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\n" . "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36\r\n" ), ); stream_context_get_default($opt); print_r(get_headers('http://i.doovoo.biz/1.php'));exit; 然后拿最后一个Location就行了 [25] => Location: https://www.lettoelectronics.com/site/www.bd.com/ [26] => HTTP/1.1 200 OK [27] => Date: Thu, 23 Jul 2015 09:05:23 GMT [28] => Server: Apache/2.2.27 (CentOS) |
5
lissome OP @feiyuanqiu
谢谢尝试,不过这个url 也是“假”的 |
6
lissome OP @feiyuanqiu
居然还仿了一个页面。。。 |
7
lissome OP 还没有搞定
|