[Tutorial] How to scrape web pages using PHP

Great tutorial, I normally use simplehtmldom, but this looks so much faster and easier!
 
Hi, i just encountered a problem on my part. see, i copy pasted your very first script.php to scrape the basics from the 2nd part of the tut. i only changed the url page of the dirtysite/ to wwwDOTpornhubDOTcom and soon as I execute the script, I automatically encountered the error:
Code:
[COLOR=#FFFFCC]PHP Fatal error:  Uncaught exception 'InvalidArgumentException' with message 'The current node list is empty.'[/COLOR]
You provided a solution on the later part of the tut, but that didn't fix the error.
My current code is this:
Code:
<?php

require 'vendor/autoload.php';

use Goutte\Client;

$client = new Client;
$client->setHeader('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/48.0.2564.97 Chrome/48.0.2564.97 Safari/537.36'); 
$crawler = $client->request('GET', 'wwwDOTpornhubDOTcom/view_video.php?viewkey=973043790');
$title = $crawler->filter('.video-wrapper .title-container .title')->first()->text();
echo $title . PHP_EOL;

# I need to close this right?
?>

My current chrome version is: Version 48.0.2564.97 m.
I changed accordingly but still, I need your help.
What am I doing wrong?
 
Back
Top