例子,php curl修改网站请求头,包括useragent、header信息等。 代码:
for ($i = 0; $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);
- }
- ?>
复制代码
|