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.
那么我的问题是:
- 服务器能否限制/阻止 cURL 传入请求?
- 如果是这样,我可以在启动 cURL 脚本中欺骗/更改 HTTP 标头(用户代理)吗?
- 或者还有其他可能的故事吗?
谢谢!
推荐答案
在服务器端,我们可以通过识别http请求中的头部字段(包括refer、cookie、user-agent等)、ip地址、访问频率来阻止一些请求.而且在大多数情况下,机器生成的请求通常与人的请求不同,例如,no refer &cookie,或者访问频率更高,我们可以写一些规则来拒绝这些请求.
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.
相关文章