Last active
November 13, 2021 03:29
-
-
Save serebano/42b55717d65f091350c656436c8f1bad to your computer and use it in GitHub Desktop.
scrapp.page/function
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.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