Skip to content

Instantly share code, notes, and snippets.

@serebano
Last active November 13, 2021 03:29
Show Gist options
  • Save serebano/42b55717d65f091350c656436c8f1bad to your computer and use it in GitHub Desktop.
Save serebano/42b55717d65f091350c656436c8f1bad to your computer and use it in GitHub Desktop.
scrapp.page/function
module.exports = async({ page }) => {
await page.goto('https://google.com/');
await page.click('button#L2AGLb', {
clickCount: 1,
delay: 200
});
await page.type('input[type="text"]', 'whats new around');
await Promise.all([
page.click('input[type="submit"]'),
page.waitForNavigation(),
]);
console.log(`I show up in the page's console!`);
const topLinks = await page.evaluate(() => {
const results = document.querySelectorAll('a');
return [...results].map(el => [el.innerText, el.getAttribute('href')]);
});
//await page.evaluate(() => { debugger; });
console.table(topLinks);
return {
type: 'json',
data: topLinks
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment