WWW :: Mechanize :: Firefox xpath according to the previous result

Is it possible to execute an XPath query for a previous result? I have this xpath:

my @objDivRes = $objBrow->xpath('//div[@id="result"]/ol/div/li', all => 1);

but when i execute the xpath function in the previous result

my @objLink = $objDivRes[0]->MozRepl::RemoteObject::Methods::xpath('//div/h3/a');

There was an error:

MozRepl::RemoteObject: TypeError: doc.evaluate is not a function at test.pl

Is there an example? thank you

+4
source share
1 answer

Just use the <node 'option to set the $ mech-> xpath ($ query,% options) subtree

Note the dot at the beginning of the path, which means subsequent node context values

my @objDivRes = $objBrow->xpath('//div[@id="result"]/ol/div/li', all => 1);

my @objLink = $objBrow->xpath('.//div/h3/a', node => $objDivRes[0]);
+1
source

Source: https://habr.com/ru/post/1533490/


All Articles