Finalized WALMART screenshots! Maybe It can be productized.

This commit is contained in:
Norm Rasmussen
2023-02-02 17:16:44 -05:00
parent 3fd15aee52
commit b9a39a8164
78 changed files with 1237 additions and 33 deletions

BIN
Scripts/.DS_Store vendored

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 399 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

View File

@ -11,10 +11,10 @@ def find_pictures():
for file in listfiles:
files.append(os.path.basename(file))
# Now file will only show the file name, not the entire path
split_resources(files)
split_resources(files, currentdir)
def split_resources(files):
def split_resources(files, currentdir):
print(files)
try:
resource_title = files[0]
@ -26,21 +26,18 @@ def split_resources(files):
new_list.append(file)
for item in new_list:
files.remove(item)
split_resources(files)
print(new_list)
process_pictures(new_list, resource_title)
split_resources(files, currentdir)
process_pictures(new_list, resource_title, currentdir)
except IndexError as e:
pass
finally:
pass
def process_pictures(new_list, resource_title):
def process_pictures(new_list, resource_title, currentdir):
today = date.today()
today = today.strftime("%m.%d.%Y")
image_list = []
print(new_list)
print(resource_title)
resource = Image.open(new_list[0])
resource = resource.convert("RGB")
for picture in new_list[1:]:
@ -49,35 +46,22 @@ def process_pictures(new_list, resource_title):
image_list.append(converted)
# image_list.append(image)
resource.save(
rf"/Users/normrasmussen/Documents/Northpass/Scripts/Walmart_Screenshots/PDFs/{resource_title}_{today}.pdf",
currentdir + f"/PDFs/{resource_title}_{today}.pdf",
save_all=True,
append_images=image_list,
)
delete_originals(currentdir)
def notusable():
image1 = Image.open(
r"/Users/normrasmussen/Documents/Northpass/Scripts/Walmart_Screenshots/Branch Wallet FAQs_1.png"
)
image2 = Image.open(
r"/Users/normrasmussen/Documents/Northpass/Scripts/Walmart_Screenshots/Branch Wallet FAQs_2.png"
)
image3 = Image.open(
r"/Users/normrasmussen/Documents/Northpass/Scripts/Walmart_Screenshots/Branch Wallet FAQs_3.png"
)
im1 = image1.convert("RGB")
im2 = image2.convert("RGB")
im3 = image3.convert("RGB")
imagelist = [im1, im2, im3]
im1.save(
r"/Users/normrasmussen/Documents/Northpass/Scripts/Walmart_Screenshots/mergedImages.pdf",
save_all=True,
append_images=imagelist,
)
def delete_originals(currentdir):
path = glob.glob(currentdir + "*.png")
for file in path:
try:
os.remove(file)
except:
print("Error!")
finally:
print("All Done")
if __name__ == "__main__":
find_pictures()

View File

@ -29,6 +29,7 @@ const url = [
]
*/
const apiKey = "6hUfJdAartHTHhHc0WIRZYPWe"
const url = process.argv[2];
if (!url) {
throw "Please provide a URL as the first argument";

View File

@ -0,0 +1,109 @@
const puppeteer = require('puppeteer');
const axios = require('axios')
const path = require('path')
const apiKey = "6hUfJdAartHTHhHc0WIRZYPWe"
const uid = "/\?uid\=7b84eae4-fb34-4689-9f33-24071c3e5a41";
const groupIds = []
const getAllGroups = async (num) => {
if(num === 1){
}
let page = num;
await axios({
method: 'get',
url: `https://api.northpass.com/v2/courses?page=${page}&limit=100`,
headers: {
'accept': '*/*',
'x-api-key': apiKey,
'content-type': 'application/json'
}
})
.then(async (res) => {
if (res.data.links.next != null) {
page++;
for (let i = 0; i < res.data.data.length; i++) {
if (res.data.data[i].attributes.status == "live") {
groupIds.push(res.data.data[i].id)
}
}
await getAllGroups(page);
} else {
for (let i = 0; i < res.data.data.length; i++) {
if (res.data.data[i].attributes.status == "live") {
groupIds.push(res.data.data[i].id)
}
}
}
})
.catch(err => {
console.log(err);
})
let i = 0
loopIds(i)
console.log(groupIds)
}
function loopIds(i) {
var num = 1
id = groupIds[i]
courseOverview(id, i, num)
}
async function courseOverview(id, i, num) {
const activity = new Array();
const url = "https://walmart.northpass.com/app/courses/";
const browser = await puppeteer.launch();
const page = await browser.newPage();
const course = url+id+uid;
console.log(course)
await page.setViewport({ width:390, height:844 })
await page.goto(course, {
waitUntil: 'load',
timeout: 0 });
await page.title();
const [getXpath] = await page.$x('/html/body/div[2]/div/div');
const resourcetitle = await page.evaluate(name => name.innerText, getXpath);
const resource = resourcetitle.trim();
console.log(resource);
await page.screenshot({path: `${resource}_1.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") && (link.includes(id))) {
console.log(link);
activity.push(link);
}
});
setTimeout(() => {
}, 5000);
uniqueLinks = [...new Set(activity)];
for (const link of uniqueLinks) {
num = num+1
const newlink = link+uid;
await page.setViewport({ width: 390, height: 844 })
await page.goto(newlink, {
waitUntil: 'load',
timeout: 0 });
await page.screenshot({path: `${resource}_${num}.png`, fullPage: true, headless: false});
//screenshots(newlink, resource, num, i);
}
await browser.close();
i++;
loopIds(i);
}
async function screenshots(newlink, resource, num, i) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await browser.close();
}
getAllGroups();