简体   繁体   English

在“ CURLOPT_URL”上停留60秒

[英]Stay on “CURLOPT_URL” for 60s

I'm using this code to test my Awstats with private proxies [4 ips] 我正在使用此代码通过私人代理[4 ips]测试我的Awstats

curl_setopt($ch, CURLOPT_URL, "http://example.com/"); 
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPGET,1); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt($ch, CURLOPT_HEADER, FALSE);  
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_PROXY, trim($privateproxylist[$p]));   

When I'm checking my stats I can see visits and refs but is there any option to make this script stay on CURLOPT_URL for 60s for each proxy? 当我查看自己的统计信息时,可以看到访问和引用,但是是否有任何选项可以使每个代理将此脚本在CURLOPT_URL上保留60秒钟? Thanks 谢谢

According to a webpage i found: 根据一个网页,我发现:

Based on the time between a visitor's first and last document access AWStats tries to calculate an average visit duration. 根据访问者首次访问文档与最后访问文档之间的时间,AWStats会尝试计算平均访问时间。

Therefore you need to wait 60s then make a request to the website again. 因此,您需要等待60秒钟,然后再次向网站提出请求。 As i don't know the internals of AWStats, you may need to use a different page url, but in theory, you should be able to just request the same url. 由于我不知道AWStats的内部信息,您可能需要使用其他页面网址,但从理论上讲,您应该能够仅请求相同的网址。 Therefore its just a case of: 因此,它只是以下情况:

// 1. Make your curl request to URL
// 2. Wait 60s
sleep(60);
// 3. Make the curl request again 
// 4. Change proxy and go back to step 1

Of course this is syncronous, so you will have the script running for a minimum of 4 minutes (based on 4 proxy ips), so dont forget to set the execution time limit of your php script to unlimited (or very high). 当然,这是同步的,因此您将使脚本至少运行4分钟(基于4个代理ips),因此请不要忘记将php脚本的执行时间限制设置为无限制(或很高)。

You may also need to set the "cookiejar" config on the curl resource, as awstats MAY use a session cookie or something like that, to identify visitors. 您可能还需要在curl资源上设置“ cookiejar”配置,因为awstats可以使用会话cookie或类似的东西来识别访问者。 So a cookiejar text file will need to be set, so the session cookie can be stored and then resent on the second request. 因此,将需要设置cookiejar文本文件,以便可以存储会话cookie,然后在第二个请求上重新发送。 Don't forget to clear the cookie file (or just set a new text file in the options) before using a new proxy ip. 在使用新的代理ip之前,请不要忘记清除cookie文件(或仅在选项中设置新的文本文件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM