I'm using the Osmosis
package to scrape like this:
require('osmosis')
.get('https://samdb.org/phones/galaxy-s10')
.find("//h4[contains(text(), 'MP')]")
.data(data=>{
console.log(data)
})
My problem is that it logs an empty object to the console, but if I try this xpath
on the website with XPath helper
it returns that h4
which I want. What am I missing?
You forgot to add the .set after the .find method in your chain.
require('osmosis')
.get('https://samdb.org/phones/galaxy-s10')
.find("//h4[contains(text(), 'MP')]")
.set('megapixel')
.data(data=>{
console.log(data)
})