-
Notifications
You must be signed in to change notification settings - Fork 0
/
practice.js
32 lines (25 loc) · 987 Bytes
/
practice.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import puppeteer from "puppeteer";
console.log("hello");
async function start() {
const browser = await puppeteer.launch(); //launches a browser
const page = await browser.newPage(); //creates a new page in brower
//screenshot
// await page.goto("https://en.wikipedia.org/wiki/JavaScript"); // page visits site
// await page.screenshot({ path: "fullpage.jpeg", fullPage: true }); //takes screenshot
// //web scrapping text only
// await page.goto("https://learnwebcode.github.io/practice-requests/");
// const names = await page.evaluate(() => {
// return Array.from(document.querySelectorAll(".info strong")).map(
// (x) => x.textContent
// );
// });
// console.log(names);
//store photos
await page.goto("https://learnwebcode.github.io/practice-requests/");
const photos = await page.$$eval("div.card > img", (imgs) => {
return imgs.map((x) => x.src);
});
console.log(photos);
await browser.close(); //closes browser
}
start();