Last active
October 20, 2022 10:34
-
-
Save opicron/a2f0b6d014c3ee744f250774fe1dd440 to your computer and use it in GitHub Desktop.
scrape #js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async ({ page }) => { | |
await page.setRequestInterception(true); | |
page.on('request', (req) => { | |
if(req.resourceType() === 'image' ){ | |
req.abort(); | |
} | |
else { | |
req.continue(); | |
} | |
}); | |
await page.setViewport({ width: 960, height: 2080 }); | |
fullUrl = 'https://www.amazon.de/SIRUI-N-2204SK-Universal-Einbeinstativ-Carbon/dp/B07GZ2VLFB'; | |
await page.goto(fullUrl); | |
page.evaluate(_ => { | |
console.log('hi'); | |
}); | |
page.keyboard.press("Tab"), | |
page.keyboard.press(String.fromCharCode(13)), | |
//page.click('a#aod-pinned-offer-show-more-link'); | |
Promise.all([ | |
page.waitForNavigation(), // wait for the page to load | |
//await page.waitForNavigation(), // wait for the page to load | |
page.click('span[data-action="show-all-offers-display"] a'), | |
]).catch(e => console.log(e)); | |
await page.waitFor(2000); | |
page.evaluate(_ => { | |
console.log('hi'); | |
}); | |
Promise.all([ | |
page.waitForNavigation(), // wait for the page to load | |
page.click('a#aod-pinned-offer-show-more-link'), | |
]).catch(e => console.log(e)); | |
await page.waitFor(1000); | |
page.evaluate(_ => { | |
console.log('hi'); | |
}); | |
//await page.WaitFor(1000); | |
//page.focus('#aod-pinned-offer-show-more-link') | |
/* | |
await Promise.all([ | |
page.click('a #aod-pinned-offer-show-more-link'), | |
page.waitForNavigation(), // wait for the page to load | |
page.click('a #aod-pinned-offer-show-more-link'), | |
]).catch(e => console.log(e)); | |
*/ | |
//await page.keyboard.press("Tab"); | |
//await page.waitFor(150); | |
//await page.keyboard.press("Tab"); | |
//await page.waitFor(150); | |
//await page.keyboard.press("Tab"); | |
//await page.waitFor(150); | |
//await page.keyboard.press("Tab"); | |
//await page.waitFor(150); | |
//await page.keyboard.press("Tab"); | |
//await page.waitFor(150); | |
//await page.keyboard.press("Tab"); | |
//await page.waitFor(150); | |
//await page.keyboard.press(String.fromCharCode(13)); | |
//await page.evaluate('document.body.innerHTML = document.body.innerHTML'); | |
}; | |
/* | |
async function nativeClick(page, button) { | |
await page.evaluate((button) => { | |
document.querySelector(button).click(); | |
}, button); | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment