PHP cURL 如何添加用户代理值或克服服务器阻止 cURL 请求?

PHP cURL how to add the User Agent value OR overcome the Servers blocking cURL requests?(PHP cURL 如何添加用户代理值或克服服务器阻止 cURL 请求?)
本文介绍了PHP cURL 如何添加用户代理值或克服服务器阻止 cURL 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在传输一个对象数组.我在自己的服务器上有一个 cURL 客户端(提交者)在其他服务器上的侦听脚本,这是我无法控制的.然后我认为,他们阻止了 传入的 cURL 请求,因为当我使用普通的 HTML <form> 进行测试时,它正在工作.但无论如何都不是通过 cURL.

I am transferring an Object Array. I have a cURL client (submitter) on own Server and listening script on other's Server, which one is not under my control. Then i think there, they are blocking the incoming cURL requests because when i test with the normal HTML <form>, it is working. But not via cURL anyway.

所以我认为他们对 cURL 做了一些限制.

So i think they have done some restriction to cURL.

那么我的问题是:

  1. 服务器能否限制/阻止 cURL 传入请求?
  2. 如果是这样,我可以在启动 cURL 脚本中欺骗/更改 HTTP 标头(用户代理)吗?
  3. 或者还有其他可能的故事吗?

谢谢!

推荐答案

  1. 在服务器端,我们可以通过识别http请求中的头部字段(包括refer、cookie、user-agent等)、ip地址、访问频率来阻止一些请求.而且在大多数情况下,机器生成的请求通常与人的请求不同,例如,no refer &cookie,或者访问频率更高,我们可以写一些规则来拒绝这些请求.

  1. In the server side, we can block some requests by recognize the header fields(including refer, cookie, user-agent and so on) in http request, the ip address, access frequency. And in most case, requests generated by machine usually has something different than human requests,for example, no refer & cookie, or with higher access frequency, we can write some rules to deny these requests.

根据1,你可以通过填充header字段,使用随机和更慢的频率,使用更多的ip地址,尽量模拟真实的请求.(听起来像是攻击)

According to 1, you can try your best to simulate real requests by filling the header fields, using random and slower frequency, using more ip addresses. (sounds like attack)

一般情况下,使用较低的频率,不给他们的服务器增加负载,遵循他们的访问规则,他们很少会阻止你的请求.

Generally, using lower frequency and do not make heavy load for their server, follow their access rules, they will seldom block your requests.

这篇关于PHP cURL 如何添加用户代理值或克服服务器阻止 cURL 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)