php curl通过代理获取数据
点击复制代码 PHP
$curl=curl_init();
curl_setopt($curl, CURLOPT_URL, "http://www.baidu.com/");
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:20.0) Gecko/20100101 Firefox/20.0');
curl_setopt($curl, CURLOPT_REFERER, 'http://www.guahao.com/');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($param));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, true);
curl_setopt($curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($curl, CURLOPT_PROXY, "180.186.11.121");
curl_setopt($curl, CURLOPT_PROXYPORT, "37211");
curl_setopt($curl, CURLOPT_PROXYUSERPWD, "taras:taras-ss5");
$result=curl_exec($curl);
点击复制代码 PHP
$curl=curl_init();
curl_setopt($curl, CURLOPT_URL, "http://www.baidu.com/");
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:20.0) Gecko/20100101 Firefox/20.0');
curl_setopt($curl, CURLOPT_REFERER, 'http://www.guahao.com/');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($param));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, true);
curl_setopt($curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($curl, CURLOPT_PROXY, "180.186.11.121");
curl_setopt($curl, CURLOPT_PROXYPORT, "37211");
curl_setopt($curl, CURLOPT_PROXYUSERPWD, "taras:taras-ss5");
$result=curl_exec($curl);
-
上一篇
php中截取中文字符串 -
下一篇
jQuery 使用Ajax无刷新提交留言及表单