Skip to content

Commit 6b8233a

Browse files
committed
initial commit
0 parents  commit 6b8233a

File tree

3,975 files changed

+284545
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,975 files changed

+284545
-0
lines changed

Save_&_Reuse_cookies/index.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const puppeteer = require("puppeteer");
2+
const prompt = require('prompt-sync')({sigint: true})
3+
4+
const main = async () => {
5+
console.clear()
6+
const browser = await puppeteer.launch({
7+
headless: false,
8+
defaultViewport: false,
9+
userDataDir: "./tmp",
10+
args:['--start-maximized' ],
11+
});
12+
const page = await browser.newPage();
13+
await page.goto('https://accounts.google.com/signin/v2/identifier', {
14+
waitUntil: "networkidle2"
15+
})
16+
17+
await page.type("#identifierId", "test.namanvyas", {delay: 500})
18+
await page.click("#identifierNext")
19+
await page.waitForNavigation({
20+
waitUntil: "networkidle2"
21+
})
22+
23+
await page.type("#password", prompt("Enter password."))
24+
await page.click("#passwordNext")
25+
await page.waitForNavigation({
26+
waitUntil: "networkidle2"
27+
})
28+
29+
const cookies = await page.cookies()
30+
console.log(cookies)
31+
32+
// browser.close()
33+
}
34+
35+
main()

basics/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const puppeteer = require("puppeteer");
2+
3+
const main = async () => {
4+
console.clear()
5+
const browser = await puppeteer.launch({
6+
headless: false
7+
});
8+
const page = await browser.newPage();
9+
await page.goto('https://example.com');
10+
await page.close();
11+
await browser.close();
12+
}
13+
14+
main()

basics/tempCodeRunnerFile.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
puppeteer

grab_html_elements/index.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const puppeteer = require("puppeteer");
2+
3+
const getProductDetails = async (producthandler) => {
4+
let title = null;
5+
let price = null;
6+
let imgUrl = null;
7+
8+
try {
9+
title = await producthandler.evaluate(el => el.querySelector('h2 > a > span').textContent)
10+
} catch (error) {}
11+
12+
try {
13+
price = await producthandler.evaluate(el => el.querySelector(".a-price > .a-offscreen").textContent)
14+
} catch (error) {}
15+
16+
try {
17+
imgUrl = await producthandler.evaluate(el => el.querySelector(".s-image").getAttribute('src'))
18+
} catch (error) {
19+
20+
}
21+
22+
return {title, price, imgUrl}
23+
}
24+
25+
const getProducts = async (page) => {
26+
let products = []
27+
const productHandles = await page.$$(".s-card-container.s-overflow-hidden.aok-relative.puis-expand-height.puis-include-content-margin.puis.s-latency-cf-section.s-card-border")
28+
29+
for (const producthandler of productHandles) {
30+
products.push(await getProductDetails(producthandler))
31+
}
32+
33+
return products
34+
}
35+
36+
const main = async () => {
37+
console.clear()
38+
const browser = await puppeteer.launch({
39+
// headless: false,
40+
defaultViewport: false,
41+
userDataDir: "./tmp",
42+
args:['--start-maximized' ],
43+
});
44+
const page = await browser.newPage();
45+
await page.goto(`https://www.amazon.com/s?rh=n%3A16225007011&fs=true&ref=1p_16225007011_sar`);
46+
47+
const products = await getProducts(page)
48+
49+
for ({title, price, imgUrl} of products) console.log(`
50+
\n
51+
Title: ${title}
52+
53+
Price: ${price}
54+
55+
imgUrl: ${imgUrl}
56+
`)
57+
58+
browser.close()
59+
}
60+
61+
main()
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
querySelector

node_modules/.bin/extract-zip

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/js-yaml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/rimraf

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.yarn-integrity

+104
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@babel/code-frame/LICENSE

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@babel/code-frame/README.md

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)