コード例 #1
0
ファイル: souq.php プロジェクト: jotalp/Hoppay2015
            $sth->execute();
            if ($sth->errorCode() != 0) {
                die("! erro linha: " . __LINE__ . "\n" . $sth->errorInfo()[2]);
            }
            $sth = $dbh->prepare("INSERT INTO Products (IdMerchant,Name,Description,Price,URL,Image,QueryDocument) VALUES (:IdMerchant,:Name::text,:Description::text,:Price,:URL,:Image,to_tsvector(:Name::text) || to_tsvector(:Description::text))");
            $sth->bindValue(":IdMerchant", self::IdMerchant);
            $sth->bindValue(":Name", $title);
            $sth->bindValue(":Description", $description);
            $sth->bindValue(":Price", $newprice);
            $sth->bindValue(":URL", $url);
            $sth->bindValue(":Image", $image);
            $sth->execute();
            if ($sth->errorCode() != 0) {
                die("! erro linha: " . __LINE__ . "\n" . $sth->errorInfo()[2]);
            }
            echo $URL . " added\n\n";
        }
        flush();
    }
}
$crawler = new MyCrawler();
$crawler->setURL("http://uae.souq.com/ae-en/");
$crawler->addReceiveContentType("#text/html#");
$crawler->setCrawlingDepthLimit(4);
$crawler->setWorkingDirectory("./tmp/");
$crawler->setUrlCacheType(PHPCrawlerUrlCacheTypes::URLCACHE_SQLITE);
while (true) {
    $crawler->goMultiProcessed(5, PHPCrawlerMultiProcessModes::MPMODE_CHILDS_EXECUTES_USERCODE);
    $report = $crawler->getProcessReport();
    sleep(15 * 60);
}