PHP curl修改网站请求头
例子,php curl修改网站请求头,包括useragent、header信息等。
代码:
<?php
for ($i = 0; $i < 5; $i++) {
task();
}
//修改访问请求头
function task() {
$url = "http://www.xxx.com/?fromuid=272539";
$ip = "100.100.".rand(1, 255).".".rand(1, 255);
$headers = array("X-FORWARDED-FOR:$ip");
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0");
$src = curl_exec($curl);
curl_close($curl);
}
?>
您可能感兴趣的文章:
PHP curl修改网站请求头
解决php curl获取网页内容提示405 method not allowed状态码
php中开启curl扩展的方法详解
curl提交json数据的方法
PHP fopen/file_get_contents与curl性能比较
php curl采集站外内容示例代码
php使用curl函数提示Call to undefined function curl_init()
php curl参数详解与用法大全
怎么将网站的php版本信息隐藏起来
curl模拟http请求范例详析