Walmart script in production! And more notes.

This commit is contained in:
Norm Rasmussen
2023-02-01 18:11:39 -05:00
parent 55eb10b0f5
commit 3fd15aee52
102 changed files with 2729 additions and 63 deletions

View File

@ -6,43 +6,49 @@ import sys
peopleCsv = "/Users/normrasmussen/Downloads/TalkspaceAllLearners.csv"
def readCsv(peopleCsv):
people = []
readExport = pd.read_csv(
peopleCsv,
usecols=['Learner Full Name', 'Email'],
skipinitialspace=True,
#index_col=True,
)
people.extend(readExport['Email'].tolist())
peopleCsv,
usecols=["Learner Full Name", "Email"],
skipinitialspace=True,
# index_col=True,
)
people.extend(readExport["Email"].tolist())
startCompare(peopleCsv, people, readExport)
# itertools combinations
def startCompare(peopleCsv, people, readExport):
email1 = []
email2 = []
for name1, name2, in itertools.combinations(people, 2):
#print(name1, name2) - prints all pairs, working so far.
for (
name1,
name2,
) in itertools.combinations(people, 2):
# print(name1, name2) - prints all pairs, working so far.
distance = lev(name1, name2)
#print(distance) - successfully returns numbers
# print(distance) - successfully returns numbers
if distance > 0 and distance < 2:
email1.append(name1)
email2.append(name2)
writenewColumn(email1, email2, peopleCsv, readExport)
def writenewColumn(email1, email2, peopleCsv, readExport):
df = pd.DataFrame(readExport)
print(df)
df['Email1'] = pd.Series(email1)
df['Email2'] = pd.Series(email2)
df.drop_duplicates('Email1', inplace=True)
df.drop_duplicates('Email2', inplace=True)
df.drop_duplicates(
subset=['Email1', 'Email2'])
#keep = 'last').reset_index(drop=True)
df["Email1"] = pd.Series(email1)
df["Email2"] = pd.Series(email2)
df.drop_duplicates("Email1", inplace=True)
df.drop_duplicates("Email2", inplace=True)
df.drop_duplicates(subset=["Email1", "Email2"])
# keep = 'last').reset_index(drop=True)
writeLst = df.to_csv(
'/Users/normrasmussen/Downloads/TalkspaceDupes_singlechange.csv',
)
"/Users/normrasmussen/Downloads/TalkspaceDupes_singlechange.csv",
)
if __name__ == "__main__":
readCsv(peopleCsv)

View File

@ -1,13 +1,13 @@
import os
import sys
from datetime import date
import glob
import shutil
import csv
import pandas as pd
rootdir = "/Users/normrasmussen/Documents/Resources/Walmart/"
downloadir = "/Users/normrasmussen/Google Drive/My Drive/Shared with Clients/Walmart_Looker/"
downloadir = (
"/Users/normrasmussen/Google Drive/My Drive/Shared with Clients/Walmart_Looker/"
)
basefile = "Walmart_Weekly_Base.xlsx"
@ -41,9 +41,9 @@ def copytoDash(latestdownload, currentDash):
# dtype={"Progress": float},
)
print(readExport)
readExport['Progress'] = readExport['Progress'].str[:-1].apply(pd.to_numeric)
readExport["Progress"] = readExport["Progress"].str[:-1].apply(pd.to_numeric)
# readExport['Progress'].apply(pd.to_numeric, errors='ignore')
print(readExport['Progress'])
print(readExport["Progress"])
readExport.drop(readExport.filter(regex="Unname"), axis=1, inplace=True)
copiedData = readExport.copy()
bringtoExcel(latestdownload, currentDash, copiedData)

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

View File

@ -0,0 +1,83 @@
from PIL import Image
import glob
import os
from datetime import date
def find_pictures():
files = []
currentdir = "/Users/normrasmussen/Documents/Northpass/Scripts/Walmart_Screenshots/"
listfiles = glob.glob(currentdir + "*.png")
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)
def split_resources(files):
print(files)
try:
resource_title = files[0]
resource_title = resource_title[:-6]
files.sort()
new_list = []
for file in files:
if resource_title in file:
new_list.append(file)
for item in new_list:
files.remove(item)
split_resources(files)
print(new_list)
process_pictures(new_list, resource_title)
except IndexError as e:
pass
finally:
pass
def process_pictures(new_list, resource_title):
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:]:
image = Image.open(picture)
converted = image.convert("RGB")
image_list.append(converted)
# image_list.append(image)
resource.save(
rf"/Users/normrasmussen/Documents/Northpass/Scripts/Walmart_Screenshots/PDFs/{resource_title}_{today}.pdf",
save_all=True,
append_images=image_list,
)
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,
)
if __name__ == "__main__":
find_pictures()

View File

@ -1,37 +1,67 @@
const puppeteer = require('puppeteer');
const path = require('path')
// const urls = [...]
/*for (let i=0; i<urls.length; i++){
/*
for (let i=0; i<urls.length; i++){
const url = urls[i];
await page.goto('${url}');
await page.waitForNavigation({ waitUntil: 'networkkidle2' });
}*/
}
const url = [
"https://walmart.northpass.com/app/courses/90bbdf4d-c674-403c-93d1-1c2e43364e0e", // Tax Filling FAQs
"https://walmart.northpass.com/app/courses/6b74d176-6027-40f5-af0c-fdee6d4f53bf", // Tips for Claiming your Branch Wallet
"https://walmart.northpass.com/app/courses/5624342f-9927-4704-bc6b-5c84068c0564", // Branch Wallet FAQs
"https://walmart.northpass.com/app/courses/65a83b52-08e9-48ac-b953-59dfa22f7358", // Pointers on Viewing your Earnings
"https://walmart.northpass.com/app/courses/0cd301a1-d98e-4837-ae9a-6fbd6a152aa3", // Curious how trip earnings works?
"https://walmart.northpass.com/app/courses/71a2064f-600d-415b-9b93-0a695793a09b", // Having Issues Confirming your arrival?
"https://walmart.northpass.com/app/courses/f9fea960-9fb3-4d05-858a-ea9a5657e20a", // Not Receiving App Notifications?
"https://walmart.northpass.com/app/courses/dce79912-ffe2-4648-a258-d725dbea6dc4", // Pointers on vehicle details
"https://walmart.northpass.com/app/courses/59a21c93-36ed-4e25-a723-6c8b3e6a80f0", // Pointers on Creating Your Account
"https://walmart.northpass.com/app/courses/17224d43-5acc-4dfb-805b-53f85cafb633", // Pointers on Downloading the App
"https://walmart.northpass.com/app/courses/bb1449eb-9b8d-48b2-9e05-1261171bd0e7", // Reviewing your trips
"https://walmart.northpass.com/app/courses/b30329fa-825f-4447-85f2-6caeea998ec6", // Pointers on Sharing Your Location
"https://walmart.northpass.com/app/courses/6c94e20c-aff7-465a-baaf-c32804fa7c9c", // Turning off Spark Now
"https://walmart.northpass.com/app/courses/2e616785-7ec7-40f0-a6a7-069f3c8c4c02", // Updating Spark Driver App
"https://walmart.northpass.com/app/courses/f3be53c0-cd21-4a2d-97f0-8b84ba030f4a", // Questions about Earnings
"https://walmart.northpass.com/app/courses/e889b1de-6305-424c-b0cd-47e36e798fa3", // Damaged Order or Item
"https://walmart.northpass.com/app/courses/8e20a3e6-37ef-4538-9047-4bcce5666d59", // Error messages & Alerts
]
*/
const apiKey = "6hUfJdAartHTHhHc0WIRZYPWe"
const url = process.argv[2];
if (!url) {
throw "Please provide a URL as the first argument";
}
const uid = "/\?uid\=7b84eae4-fb34-4689-9f33-24071c3e5a41";
const activity = new Array();
const activityLinks = new Array();
var num = 0
var num = 1
/*
function loopUrls() {
for (item of url){
console.log(item)
courseOverview()
}
}*/
async function courseOverview() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const course = url+uid;
await page.setViewport({ width:390, height:844 })
await page.goto(url);
await page.goto(course);
await page.title();
const [getXpath] = await page.$x('//*[@id="course-desktop"]/div/div[3]/div[2]/div[2]/div[2]/ol/li/div');
const [getXpath] = await page.$x('/html/body/div[2]/div/div');
// 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});
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);
@ -44,9 +74,8 @@ async function courseOverview() {
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)
// console.log(newlink)
screenshots(newlink, resource, num);
}
await browser.close();