WALMART SCREENSHOT SCRIPT DONEcd ~/Documents/Northpass! And emails from Groups for Wildhealth. Very productive day

This commit is contained in:
Norm Rasmussen
2023-01-31 16:24:35 -05:00
parent ab43ce9d90
commit 55eb10b0f5
17 changed files with 103 additions and 49 deletions

BIN
Scripts/Walmart_Screenshots/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -0,0 +1,64 @@
const puppeteer = require('puppeteer');
const path = require('path')
// const urls = [...]
/*for (let i=0; i<urls.length; i++){
const url = urls[i];
await page.goto('${url}');
await page.waitForNavigation({ waitUntil: 'networkkidle2' });
}*/
const url = process.argv[2];
if (!url) {
throw "Please provide a URL as the first argument";
}
const activity = new Array();
const activityLinks = new Array();
var num = 0
async function courseOverview() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width:390, height:844 })
await page.goto(url);
await page.title();
const [getXpath] = await page.$x('//*[@id="course-desktop"]/div/div[3]/div[2]/div[2]/div[2]/ol/li/div');
const resourcetitle = await page.evaluate(name => name.innerText, getXpath);
const resource = resourcetitle.trim();
console.log(resource);
await page.screenshot({path: `${resource}.png`, fullPage:true, headless:false});
const hrefs = await page.$$eval('a', as => as.map(a => a.href));
var links = Object.entries(hrefs);
links.forEach(([key, value]) => {
var link = value;
if (link.includes("activities")) {
activity.push(link);
}
});
uniqueLinks = [...new Set(activity)];
for (const link of uniqueLinks) {
num = num+1
let uid = "?uid\=7b84eae4-fb34-4689-9f33-24071c3e5a41"
const newlink = link+uid;
console.log(newlink)
screenshots(newlink, resource, num);
}
await browser.close();
}
async function screenshots(newlink, resource, num) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 390, height: 844 })
await page.goto(newlink);
await page.screenshot({path: `${resource}_${num}.png`, fullPage: true, headless: false});
await browser.close();
}
courseOverview();