Soldato
- Joined
- 7 Jan 2007
- Posts
- 10,607
- Location
- Sussex, UK
Hi,
I'm trying to create a script that will pull in data from a remote html page, more accurately a cell within a table.
I have used the bbc Top prem goal scorers table for this example I am trying to echo the text "Nolan".
However, I get a this error with the script below:
Catchable fatal error: Object of class DOMNodeList could not be converted to string in C:\wamp\www\scrape.php on line 26
Now from googling, it seems that a 'DOMNodeList' cannot be displayed as a string.
I'm not sure how to proceed. Any ideas?
If I can fix this script, I'm wondering in it's current form does it execute every time the page loads? If it does how would I get it to only execute once every hour?
So, if I had 10 people on the page it would execute 10 times?
I'm trying to create a script that will pull in data from a remote html page, more accurately a cell within a table.
I have used the bbc Top prem goal scorers table for this example I am trying to echo the text "Nolan".
However, I get a this error with the script below:
Catchable fatal error: Object of class DOMNodeList could not be converted to string in C:\wamp\www\scrape.php on line 26
Now from googling, it seems that a 'DOMNodeList' cannot be displayed as a string.
I'm not sure how to proceed. Any ideas?
If I can fix this script, I'm wondering in it's current form does it execute every time the page loads? If it does how would I get it to only execute once every hour?
So, if I had 10 people on the page it would execute 10 times?
PHP:
<?php
$my_url = 'http://news.bbc.co.uk/sport1/hi/football/eng_prem/top_scorers/default.stm';
$html = file_get_contents($my_url);
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$my_xpath_query = "/html/body[@id='body']/div[1]/div[@id='blq-container']/div[@id='blq-container-inner']/div[@id='blq-main']/div/table/tbody/tr/td[2]/table[1]/tbody/tr/td[1]/table[1]/tbody/tr[6]/td[1]";
$text = $xpath->query($my_xpath_query);
echo "$text";
?>