I need to scrape a length of text from a webpage from the internet, I am using the dom and xpath to find the data, however I cant seem to select the exact information I need. He
Running your code, I first get :
Notice: Undefined variable: expr_argos
Warning: DOMXPath::query() [domxpath.query]: Invalid expression
So, first of all, make sure you are using something valid for your XPath query -- for example, you should have this :
$nodes_argos = $xpath_argos->query($expr_currys);
instead of what you currently have :
$nodes_argos = $xpath_argos->query($expr_argos);
Then, you get the following error :
Notice: Trying to get property of non-object
on the following line :
$argos_stock_data = $nodes_argos->item(0)->nodeValue;
Basically, this means you are trying to read a property, nodeValue
, on something that is not an object : $nodes_argos->item(0);
I'm guessing your XPath query is not valid ; so, the call to the xpath()
method doesn't return anything interesting.
You should check your (quite a bit too long to be easy to understand) XPath query, making sure it matches something in your HTML page.