php curl设置代理_使用PHP cURL设置用户代理

php curl设置代理

A few months back, I shared with you how to download the contents of a URL and execute a HTTP POST transmission using PHP cURL. For security purposes, some hosts require that a common user agent be present in the POST. If an unacceptable user agent is given, the POST is ignored. Luckily, cURL allows us to "spoof" the server using any user agent we choose:

几个月前,我与您分享了如何下载URL的内容以及如何使用PHP cURL 执行HTTP POST传输 。 为了安全起见,某些主机要求POST中包含一个公共用户代理。 如果给出了不可接受的用户代理,则忽略POST。 幸运的是,cURL允许我们使用我们选择的任何用户代理来“欺骗”服务器:

curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');

A little sneaky but it could get you out of a jam at some point!

有点偷偷摸摸,但在某些时候它可能使您摆脱困境!

翻译自: https://davidwalsh.name/set-user-agent-php-curl-spoof

php curl设置代理

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值