curl命令
-------------------
给某个网址POST数据:
curl -d "id=1234" http://www.example.net/VoteAction.php
在curl里添加代理IP:
curl -x 219.136.206.29:80 -d "id=1234" http://www.example.net/VoteAction.php
如果我们要投票的网站只是检测代理IP,那么,上述命令就能自动投票了。我们用PHP脚本,去某些代理网站抓取代理IP和端口,然后用exec调用拼凑好的命令。
/*------------获取proxy--------------*/
$urlList = array(
//'http://www.sooip.cn/Article_Show.asp?ArticleID=2141',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3961',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3959',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3956',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3951',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3948',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3946',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3944',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3939',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3933',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3909',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3907',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3904',
'http://www.sooip.cn/Article_Show.asp?ArticleID=3900'
);
$result = array();
foreach($urlList as $url) {
echo "\nParsing web page: {$url}";
$tmpHtml = file_get_contents($url);
preg_match_all("/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\d{1,4})\s+HTTP/i", $tmpHtml, $matches);
for ($i=0; $i< count($matches[0]); $i++) {
$result[] = $matches[1][$i] . ":" . $matches[2][$i];
}
}
echo "\nParse excuted successfully!";
/*------------逐个投票--------------*/
echo "\n\n\nStart to vote:";
$i = 1;
$proxyList = $result;
while(!empt y($proxyList)) {
//empty多了个空格
$proxy = array_shift($proxyList);
echo "\n\nNo.{$i}\n";
//暂停,控制投票频率
$pauseSeconds = rand(10, 30);
echo "pausing: {$pauseSeconds} s\n";
sleep($pauseSeconds);
//执行投票
echo "vote from: {$proxy} \n";
echo "----------------------\n";
exec('curl -x ' . $proxy . ' -d "id=1234" http://www.example.net/VoteAction.php');
$i++;
}
echo "\ndone!";
参考资料
-------------------
《Linux curl使用简单介绍 - curl - songbei6's blog 》,还提到了如何对付cookie!
后续文章
-------------------
(完)