Goutte 一个简单易用的 PHP 爬虫类库
Goutte 提供了优雅的 API 进行链接抓取,和解析 HTML 文档。
以下示例代码用来抓取 PHPUnit 的文档:
public function scrapePHPUnitDe()
{
$client = new Client();
$crawler = $client->request('GET', 'https://phpunit.de/manual/current/en/index.html');
$toc = $crawler->filter('.toc');
file_put_contents(base_path('resources/docs/').'index.html', $toc->html());
$crawler->filter('.toc > dt a')->each(function($node) use ($client) {
$href = $node->attr('href');
$this->info("Scraped: " . $href);
$crawler = $client->request('GET', $href);
$chapter = $crawler->filter('.col-md-8 .chapter, .col-md-8 .appendix')->html();
file_put_contents(base_path('resources/docs/').$href, $chapter);
});
}
Goutte 主要使用以下 PHP 类库:
- 页面解析:Symfony 的 BrowserKit , CssSelector 和 DomCrawler;
- HTTP 请求: Guzzle
本作品采用《CC 协议》,转载必须注明作者和本文链接
本帖由系统于 6年前 自动加精
非常好的采集插件
请问,有没有关于项目中关于前端的命名规范的文档
链接加密了 没用规则可寻,可以爬吗?
github.com/echo-LuGuang/nothing_to...
php爬虫 基于workerman 已开源