Kha*_*een 7 php bookmarklet scrapy web-scraping
我可以在PHP上使用Scrapy,还是有与PHP一起使用的类似工具?
我不是技术人员,只是研究可用的网络抓取工具及其功能,以支持我的技术同事.
Scrapy是用于python的,您不能在PHP中使用它。
但是,在PHP中,您可以使用Goutte来完成这项工作。它在后台使用Guzzle HTTP和Symfony组件(例如BrowserKit和DomCrawler)来完成此工作。
看一下这个:
use Goutte\Client;
$client = new Client();
// Go to the symfony.com website
$crawler = $client->request('GET', 'http://www.symfony.com/blog/');
// Get the latest post in this category and display the titles
$crawler->filter('h2 > a')->each(function ($node) {
echo $node->text().'\n';
});
Run Code Online (Sandbox Code Playgroud)
PS:请注意,它不支持JavaScript。