I'm trying to get the reviews in aliexpress but for some reason wait()
function always fail to find #transction-feedback
So technically if you go to that link and click Feedback tap it will show all the reviews
.click does work because it clicks the tab, but seems like #transction-feedback
never shows up. I tried to recreate the same using the browser and #transction-feedback
shows up.
Here's the code
const cheerio = require('cheerio')
const Nightmare = require('nightmare')
const nightmare = Nightmare({
show: true
})
const URL = 'https://www.aliexpress.com/item/Samsung-Earphones-EHS64-Headsets-With-Built-in-Microphone-3-5mm-In-Ear-Wired-Earphone-For-Smartphones/32854052487.html?spm=2114.search0103.3.1.51dd26c3CxZ3zZ&ws_ab_test=searchweb0_0,searchweb201602_8_10065_10068_319_10059_10884_317_10887_10696_321_322_10084_453_10083_454_10103_10618_10307_537_536,searchweb201603_50,ppcSwitch_0&algo_expid=5587ff37-5e3a-45a8-8206-7b182433a961-0&algo_pvid=5587ff37-5e3a-45a8-8206-7b182433a961'
nightmare
.goto(URL)
.click('li[data-trigger="feedback"]')
.wait('#transction-feedback')
.evaluate(() => {
return document.body.innerHTML
})
.end()
.then((result) => {
const $ = cheerio.load(result)
res.json($.html())
})
.catch(error => {
console.error('Search failed:', error)
})
I tried on Puppeteer as well but doesnt work
const puppeteer = require('puppeteer');
const URL = 'https://www.aliexpress.com/item/Samsung-Earphones-EHS64-Headsets-With-Built-in-Microphone-3-5mm-In-Ear-Wired-Earphone-For-Smartphones/32854052487.html?spm=2114.search0103.3.1.51dd26c3CxZ3zZ&ws_ab_test=searchweb0_0,searchweb201602_8_10065_10068_319_10059_10884_317_10887_10696_321_322_10084_453_10083_454_10103_10618_10307_537_536,searchweb201603_50,ppcSwitch_0&algo_expid=5587ff37-5e3a-45a8-8206-7b182433a961-0&algo_pvid=5587ff37-5e3a-45a8-8206-7b182433a961'
async function testPupp() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(URL);
await page.evaluate(() => {
document.querySelector('li[data-trigger="feedback').click();
console.log(document.body.innerHTML)
});
await browser.close();
}
testPupp()
What should I do?