且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-02-24 18:29:59

  1. 在服务器端,我们可以通过识别http请求中的header字段(包括refer、cookie、user-agent等)、ip地址、访问频率来拦截一些请求.并且在大多数情况下,机器生成的请求通常与人类的请求有所不同,例如,没有引用 &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.