这是一个包含多个站点的简单爬网,但它失败了

时间:2013-02-26 00:42:51

标签: php arrays curl

我是一个n00b,所以请忍受这些愚蠢的问题 - 我知道我的卷曲命令工作我可以一次做一个但是当我添加这个数组并反击它只是不起作用。 我知道这是基础,但我已经尝试寻找东西,这看起来应该有用。当然我错了帮助,

<?php
$proxy = '127.0.0.1:8118';
$proxy = explode(':', $proxy);
$site[] = "http://site1.com";
$site[] = "http://site2.com";
$site[] = "http://site3.com";
$site[] = "http://site4.com";
// $site[] = explode(':', $site[]);
$maxsites = count($site);

// echo $site[];
echo $maxsites;

$counter ='1';

echo $counter;
echo "site count ".$site[$counter];

while  (  $counter <= 4);
{
echo "got to here";
    $url = $site[$counter];
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $site[$counter]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
    curl_setopt($ch, CURLOPT_PROXY, $proxy[0]);
    curl_setopt($ch, CURLOPT_PROXYPORT, $proxy[1]);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    $exec = curl_exec($ch);
    echo curl_error($ch);
    print_r(curl_getinfo($ch));
    echo $exec;
    $counter++;
}
?>

0 个答案:

没有答案