regex - Xpath to find prices in a web page -


i trying extract prices , currency in html page (for exampe this webpage) using xpath expression.

i tried:

$x("//*[matches(text(),'^\$\d+\.\d{1,2}')]") 

in firefox's console prints undefined. solution based on regular expressions.

from example, because use matches, deduce use xpath 2. probably, not supported browser. check xpath version.

another version work xpath 1 described below.

notice xpath <span> elements looks like:

//*[@id="result_0"]/div/div[3]/div[1]/a/span //*[@id="result_1"]/div/div[3]/div[1]/a/span //*[@id="result_2"]/div/div[3]/div[1]/a/span 

so, need use regular expression id , text span.

you can use matches (xpath2) or starts-with (xpath1) first part , text() text span. so, test in browser, use this:

$x('//*[starts-with(@id,"result_")]/div/div[3]/div[1]/a/span/text()') 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -