Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Scrapy work on PHP?

Can I use Scrapy on PHP or are there similar tools that work with PHP?

I am not a technical person but just researching the available web scraping tools and their features to support my technical colleagues.

like image 225
Khaled Shaheen Avatar asked Jan 20 '14 13:01

Khaled Shaheen


1 Answers

Scrapy is for python and you can't use that in PHP.

However, in PHP you can use Goutte to do this job. It uses Guzzle HTTP and Symfony components like BrowserKit and DomCrawler behind the scenes to do this job.

Check this out:

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';
});

More on usage

PS: Please do note that it doesn't do JavaScript.

like image 169
kabirbaidhya Avatar answered Oct 01 '22 07:10

kabirbaidhya