-5

I'm new to PHP Data scraping, I've looked over the other threads and I couldn't find what I needed. I wanted to make a script that will constantly check a website if the infomation has changed, at the same time get the infomation. For example: google.com I want to grab just the "Google Search" but at the same time, it will check every so often incase it has changed. Cheers!

$html = file_get_contents( $url);

libxml_use_internal_errors( true);
$doc = new DOMDocument;
$doc->loadHTML( $html);
$xpath = new DOMXpath( $doc);


$node = $xpath->query( '//div[@name="jsb"]')->item( 0);

echo $node->textContent; 
Paul Brennan
  • 73
  • 1
  • 3
  • 11
  • you have added code - great. but whats the issue with the code? are you saying it does not work? if so in what way? –  Jan 25 '16 at 21:30
  • And what is your problem and/or question? – Charlotte Dunois Jan 25 '16 at 21:31
  • @Dagon I get the following errors: Notice: Undefined variable: url in C:\xampp\htdocs\test.php on line 2 Warning: file_get_contents(): Filename cannot be empty in C:\xampp\htdocs\test.php on line 2 Warning: DOMDocument::loadHTML(): Empty string supplied as input in C:\xampp\htdocs\test.php on line 6 Notice: Trying to get property of non-object in C:\xampp\htdocs\test.php on line 12 – Paul Brennan Jan 25 '16 at 21:32
  • 1
    error seems clear, where is `$url` ever defined? –  Jan 25 '16 at 21:39

1 Answers1

1

PHP Simple HTML DOM Parser would be a great place to start and the also read up on Cronjobs

But show us what you got so far, so we can help you, we are not going to write the code for you.

Edit:

the problem is with this line:

$html = file_get_contents($url);

where is the $url defined? it looks like it is empty, you can try and replace it with the website link so it looks like this.

$html = file_get_contents("http://domain.tld/page");
Community
  • 1
  • 1
keja
  • 1,333
  • 1
  • 14
  • 21
  • Thanks for fixing that, I'm blind.... But now I get this error: Notice: Trying to get property of non-object in C:\xampp\htdocs\test.php on line 12 – Paul Brennan Jan 25 '16 at 21:42
  • that would be your xpath that is incorrect i would guess. – keja Jan 25 '16 at 21:47