欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php代理采集代码

程序员文章站 2024-01-20 12:43:40
...
php代理采集代码。
function curl_content ($url){
$user_agent = "Mozilla/4.0";
$proxy = "http://".get_proxy();
$ch = curl_init();
curl_setopt ($ch, CURLOPT_PROXY, $proxy);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt ($ch, CURLOPT_COOKIEJAR, "e:\www\cookie.txt");
curl_setopt ($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
$result = curl_exec ($ch);
curl_close($ch);
return $proxy.$result;
}

function get_proxy(){
$proxys = 107.151.136.202:80
1.34.223.206:80
1.34.223.229:80
189.8.82.82:80
str;
$proxys = explode("\r\n", $proxys);
$key = rand(1,count($proxys))-1;
return $proxys[$key];
}
代理ip自己网上采。。
用代理ip采集网站内容。。。

微信公众号导航 http://www.phpstd.com/wxjun
给予thinkhp3.2.3 全自动采集更新 全站连同前台共300行代码。

AD:真正免费,域名+虚机+企业邮箱=0元