PHP CURL方式使用代理访问网站

栏目: PHP · 发布时间: 6年前

内容简介:抓取接口数据 但对方网站有限速规则 , 为了防止被限制 使用最后更新于

抓取接口数据 但对方网站有限速规则 , 为了防止被限制 使用

curl_setopt ($ch, CURLOPT_URL, $requestUrl);
  
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); //代理认证模式
  
curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1"); //代理服务器地址
  
curl_setopt($ch, CURLOPT_PROXYPORT, 80); //代理服务器端口
  
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, ":"); //http代理认证帐号,名称:pwd的格式
  
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); //使用http代理模式

curl_setopt($ch, CURLOPT_USERAGENT, 'curl); //设置用户代理

最后更新于 2018-12-28 09:19:40 并被添加「curl」标签,已有 3 位童鞋阅读过。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Cracking the Coding Interview

Cracking the Coding Interview

Gayle Laakmann McDowell / CareerCup / 2015-7-1 / USD 39.95

Cracking the Coding Interview, 6th Edition is here to help you through this process, teaching you what you need to know and enabling you to perform at your very best. I've coached and interviewed hund......一起来看看 《Cracking the Coding Interview》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具