[英]What PHP web crawler libraries are available?
我正在尋找一些健壯的,記錄良好的PHP Web爬蟲腳本。 也許是Java項目的PHP端口 - http://wiki.apache.org/nutch/NutchTutorial
我正在尋找免費和非免費版本。
https://github.com/fabpot/Goutte也是一個兼容psr-0標准的好庫。
試試Snoopy吧。
摘錄:“Snoopy是一個模擬Web瀏覽器的PHP類。它可以自動執行檢索網頁內容和發布表單的任務。”
這里有一個greate教程,它結合了guzzlehttp和symfony / dom-crawler
如果鏈接丟失,這里是您可以使用的代碼。
use Guzzle\Http\Client;
use Symfony\Component\DomCrawler\Crawler;
use RuntimeException;
// create http client instance
$client = new GuzzleHttp\ClientClient('http://download.cloud.com/releases');
// create a request
$response = $client->request('/3.0.6/api_3.0.6/TOC_Domain_Admin.html');
// get status code
$status = $response->getStatusCode();
// this is the response body from the requested page (usually html)
//$result = $response->getBody();
// crate crawler instance from body HTML code
$crawler = new Crawler($response->getBody(true));
// apply css selector filter
$filter = $crawler->filter('div.apismallbullet_box');
$result = array();
if (iterator_count($filter) > 1) {
// iterate over filter results
foreach ($filter as $i => $content) {
// create crawler instance for result
$cralwer = new Crawler($content);
// extract the values needed
$result[$i] = array(
'topic' => $crawler->filter('h5')->text();
'className' => trim(str_replace(' ', '', $result[$i]['topic'])) . 'Client'
);
}
} else {
throw new RuntimeException('Got empty result processing the dataset!');
}
您可以使用PHP Simple HTML DOM Parser 。 它非常簡單實用。
在我發現phpQuery之前,我已經使用Simple HTML DOM大約3年了。 它的速度要快得多,不能遞歸地工作(你可以實際轉儲它)並且完全支持jQuery選擇器和方法。
如果你正在考慮一個強大的基礎組件而不是嘗試http://symfony.com/doc/2.0/components/dom_crawler.html
它很棒,有像css選擇器這樣的功能。
我知道這是一個有點老問題。 從那時起,出現了許多有用的庫。
給Crawlzone一個機會 。 它是一個快速,文檔齊全的異步Internet爬網框架,具有許多強大的功能:
另請查看我寫的關於它的文章:
https://www.codementor.io/zstate/this-is-how-i-crawl-n98s6myxm
沒人提到wget是一個很好的起點?
wget -r --level=10 -nd http://www.mydomain.com/
更多@ http://www.erichynds.com/ubuntulinux/automatically-crawl-a-website-looking-for-errors/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.