首页  >  文章  >  后端开发  >  php curl通过代理获取数据

php curl通过代理获取数据

WBOY
WBOY原创
2016-07-25 08:42:14883浏览
  1. $curl=curl_init();
  2. curl_setopt($curl, CURLOPT_URL, "http://www.baidu.com/");
  3. curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:20.0) Gecko/20100101 Firefox/20.0');
  4. curl_setopt($curl, CURLOPT_REFERER, 'http://www.guahao.com/');
  5. curl_setopt($curl, CURLOPT_POST, true);
  6. curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($param));
  7. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  8. curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, true);
  9. curl_setopt($curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
  10. curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
  11. curl_setopt($curl, CURLOPT_PROXY, "180.186.11.121");
  12. curl_setopt($curl, CURLOPT_PROXYPORT, "37211");
  13. curl_setopt($curl, CURLOPT_PROXYUSERPWD, "taras:taras-ss5");
  14. $result=curl_exec($curl);
复制代码

php, curl


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn