php 带header访问测试接收端

crawl.php 源码

require __DIR__ . '/../common.main.php';
$url = 'http://zhuwang.com/test.php';
$header = array(
        'Content-Type:application/x-www-form-urlencoded',
 		'Referer: http://www.baidu.com/',
		'Cookie: __gads=ID=648c5a667fff369e-22b2ef65efc400b7:T=1606535298:RT=1606535298:S=ALNI_MZYHLlnm6C2Gb2o9_zZjYdJIdezsw; Ajiangcount%5Fstat1=Ajstat2=1; AjStatcount%5Fstat1=UserPages=1&AjstatPages=1',
        'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'); 
 
$shtml = request($url,$header);
echo $shtml;

test.php 只写一句话

var_dump($_SERVER);

执行以下

/bin/php crawl.php

array(31) {
[“UNIQUE_ID”]=>
string(24) “X@lU98CoAGUAAAVAHcUAAAAD”
[“HTTP_HOST”]=>
string(11) “zhuwang.com”
[“HTTP_ACCEPT”]=>
string(3) “*/*”
[“CONTENT_TYPE”]=>
string(33) “application/x-www-form-urlencoded”
[“HTTP_REFERER”]=>
string(21) “http://www.baidu.com/”
[“HTTP_COOKIE”]=>
string(185) “__gads=ID=648c5a667fff369e-22b2ef65efc400b7:T=1606535298:RT=1606535298:S=ALNI_MZYHLlnm6C2Gb2o9_zZjYdJIdezsw; Ajiangcount%5Fstat1=Ajstat2=1; AjStatcount%5Fstat1=UserPages=1&AjstatPages=1”
[“HTTP_USER_AGENT”]=>
string(114) “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36”
[“PATH”]=>
string(29) “/usr/bin:/bin:/usr/sbin:/sbin”
[“DYLD_LIBRARY_PATH”]=>
string(34) “/Applications/XAMPP/xamppfiles/lib”
[“SERVER_SIGNATURE”]=>
string(0) “”
[“SERVER_SOFTWARE”]=>
string(76) “Apache/2.4.7 (Unix) PHP/5.5.9 OpenSSL/1.0.1f mod_perl/2.0.8-dev Perl/v5.16.3”
[“SERVER_NAME”]=>
string(11) “zhuwang.com”
[“SERVER_ADDR”]=>
string(9) “127.0.0.1”
[“SERVER_PORT”]=>
string(2) “80”
[“REMOTE_ADDR”]=>
string(9) “127.0.0.1”
[“DOCUMENT_ROOT”]=>
string(39) “/Users/ge/ge/web/php/ownphp/zhuwang.com”
[“REQUEST_SCHEME”]=>
string(4) “http”
[“CONTEXT_PREFIX”]=>
string(0) “”
[“CONTEXT_DOCUMENT_ROOT”]=>
string(39) “/Users/ge/ge/web/php/ownphp/zhuwang.com”
[“SERVER_ADMIN”]=>
string(32) “webmaster@dummy-host.example.com”
[“SCRIPT_FILENAME”]=>
string(48) “/Users/ge/ge/web/php/ownphp/zhuwang.com/test.php”
[“REMOTE_PORT”]=>
string(5) “53122”
[“GATEWAY_INTERFACE”]=>
string(7) “CGI/1.1”
[“SERVER_PROTOCOL”]=>
string(8) “HTTP/1.1”
[“REQUEST_METHOD”]=>
string(3) “GET”
[“QUERY_STRING”]=>
string(0) “”
[“REQUEST_URI”]=>
string(9) “/test.php”
[“SCRIPT_NAME”]=>
string(9) “/test.php”
[“PHP_SELF”]=>
string(9) “/test.php”
[“REQUEST_TIME_FLOAT”]=>
float(1609127159.618)
[“REQUEST_TIME”]=>
int(1609127159)
}

HTTP_REFERER

HTTP_COOKIE
都带过来了,这时候就说明如果要模拟cookie或者reffer就容易多了。

反爬虫启示:判断reffer可以解决大量图片盗链问题。


This entry was posted in PHP and tagged . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/php-header-2/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.
2020.03.24 评论已经全局关闭,有事加QQ聊天