Last active
August 16, 2022 20:38
-
-
Save helb/f91a3b3075b3c60367ac10196109492e to your computer and use it in GitHub Desktop.
puppeteer-search-example
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
const puppeteer = require("puppeteer"); | |
const websites = [ | |
{ url: "https://www.antikvariaty.cz/", search: "input[name=fulltxt]", submit: "button[type=submit]" }, | |
{ url: "https://www.trhknih.cz/", search: "input#searchbox", submit: "button[type=submit]" }, | |
{ url: "https://antikvariat11.cz/", search: "input#searchbox", submit: "input[name=Submit]" }, | |
{ url: "https://www.antikvariat-benes.cz/", search: "input.srch_input", submit: "a.srch_btn" }, | |
{ url: "https://www.antikvariat-levneknihy.cz/", search: "input[name=hledany_text]", submit: "input.submit" } | |
]; | |
(async () => { | |
const query = process.argv.slice(2).join(" "); | |
const browser = await puppeteer.launch({ headless: false }); | |
websites.forEach(async website => { | |
const page = await browser.newPage(); | |
await page.goto(website.url, { waitUntil: "networkidle2" }); | |
await page.focus(website.search); | |
await page.type(website.search, query); | |
await page.click(website.submit); | |
}); | |
})(); |
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
const puppeteer = require("puppeteer"); | |
const keywords = ["kůže", "brašnářství"]; | |
const website = { | |
url: "https://www.kosmas.cz/", | |
search: "input#searchInput", | |
submit: "button#searchButton" | |
}; | |
(async () => { | |
const browser = await puppeteer.launch({ headless: false }); | |
keywords.forEach(async query => { | |
const page = await browser.newPage(); | |
await page.goto(website.url, { waitUntil: "networkidle2" }); | |
await page.focus(website.search); | |
await page.type(website.search, query); | |
await page.click(website.submit); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment