From ee04a06e0e4b243eac48aff3fb52d7fc90c9a382 Mon Sep 17 00:00:00 2001 From: NMerz Date: Sun, 1 Nov 2020 11:30:03 -0500 Subject: [PATCH] Chaining, retries, and general scraping durability Make the scraping infrastructure more durable since the scraping service often fails to deliver --- Lambdas/Scraping/KohlsScraper.py | 20 +++++++++++-- Lambdas/Scraping/buildKohlsZip.sh | 1 + Lambdas/Scraping/buildRunOrchestratorZip.sh | 5 ++++ Lambdas/Scraping/prefix_list_builder.py | 32 +++++++++++++-------- Lambdas/Scraping/prefix_list_part1.txt | 2 +- Lambdas/Scraping/prefix_list_part10.txt | 1 + Lambdas/Scraping/prefix_list_part11.txt | 1 + Lambdas/Scraping/prefix_list_part12.txt | 1 + Lambdas/Scraping/prefix_list_part13.txt | 1 + Lambdas/Scraping/prefix_list_part14.txt | 1 + Lambdas/Scraping/prefix_list_part15.txt | 1 + Lambdas/Scraping/prefix_list_part16.txt | 1 + Lambdas/Scraping/prefix_list_part2.txt | 2 +- Lambdas/Scraping/prefix_list_part3.txt | 1 + Lambdas/Scraping/prefix_list_part4.txt | 1 + Lambdas/Scraping/prefix_list_part5.txt | 1 + Lambdas/Scraping/prefix_list_part6.txt | 1 + Lambdas/Scraping/prefix_list_part7.txt | 1 + Lambdas/Scraping/prefix_list_part8.txt | 1 + Lambdas/Scraping/prefix_list_part9.txt | 1 + Lambdas/Scraping/runOrchestrator.py | 17 +++++++++-- 21 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 Lambdas/Scraping/buildRunOrchestratorZip.sh create mode 100644 Lambdas/Scraping/prefix_list_part10.txt create mode 100644 Lambdas/Scraping/prefix_list_part11.txt create mode 100644 Lambdas/Scraping/prefix_list_part12.txt create mode 100644 Lambdas/Scraping/prefix_list_part13.txt create mode 100644 Lambdas/Scraping/prefix_list_part14.txt create mode 100644 Lambdas/Scraping/prefix_list_part15.txt create mode 100644 Lambdas/Scraping/prefix_list_part16.txt create mode 100644 Lambdas/Scraping/prefix_list_part3.txt create mode 100644 Lambdas/Scraping/prefix_list_part4.txt create mode 100644 Lambdas/Scraping/prefix_list_part5.txt create mode 100644 Lambdas/Scraping/prefix_list_part6.txt create mode 100644 Lambdas/Scraping/prefix_list_part7.txt create mode 100644 Lambdas/Scraping/prefix_list_part8.txt create mode 100644 Lambdas/Scraping/prefix_list_part9.txt diff --git a/Lambdas/Scraping/KohlsScraper.py b/Lambdas/Scraping/KohlsScraper.py index 8dba24c..69e2c69 100644 --- a/Lambdas/Scraping/KohlsScraper.py +++ b/Lambdas/Scraping/KohlsScraper.py @@ -2,11 +2,12 @@ import requests import json from bs4 import BeautifulSoup - import pymysql.cursors import time +from random import randint import re + def lambda_handler(event, context): print(event["toScrape"]) scraper_configs = None @@ -19,14 +20,27 @@ def lambda_handler(event, context): } params = ( - ("url","https://www.kohls.com/search.jsp?submit-search=web-regular&search="+ event["toScrape"]), + ("url","https://www.kohls.com/search.jsp?submit-search=web-regular&search=" + event["toScrape"]), ("location","na"), ); response = requests.get("https://app.zenscrape.com/api/v1/get", headers=headers, params=params) - + + retry_counter = 1 + while response.status_code == 500: + print("Retry #" + str(retry_counter)) + retry_counter += 1 + time.sleep(randint(5,20)) + response = requests.get("https://app.zenscrape.com/api/v1/get", headers=headers, params=params) + + if response.status_code != 200: + print("Scraping status code: " + str(response.status_code )) + print(response.text) + + soup = BeautifulSoup(response.text, "html.parser") + insert_params = [] for match in soup.find_all(id=re.compile(".*_prod_price")): diff --git a/Lambdas/Scraping/buildKohlsZip.sh b/Lambdas/Scraping/buildKohlsZip.sh index 59d85f6..a868fd3 100644 --- a/Lambdas/Scraping/buildKohlsZip.sh +++ b/Lambdas/Scraping/buildKohlsZip.sh @@ -1,5 +1,6 @@ #!/bin/bash #Currently to be run only from the Scraping directory +rm artifacts/kohlsScraper.zip OLDPWD=$(pwd) cd build/ zip -r9 ${OLDPWD}/artifacts/kohlsScraper.zip . diff --git a/Lambdas/Scraping/buildRunOrchestratorZip.sh b/Lambdas/Scraping/buildRunOrchestratorZip.sh new file mode 100644 index 0000000..fa1b72f --- /dev/null +++ b/Lambdas/Scraping/buildRunOrchestratorZip.sh @@ -0,0 +1,5 @@ +#!/bin/bash +#Currently to be run only from the Scraping directory +rm artifacts/runOrchestrator.zip +zip -r9 artifacts/runOrchestrator.zip prefix_list_part*.txt +zip -r9 artifacts/runOrchestrator.zip runOrchestrator.py diff --git a/Lambdas/Scraping/prefix_list_builder.py b/Lambdas/Scraping/prefix_list_builder.py index d5bbe2b..0043c26 100644 --- a/Lambdas/Scraping/prefix_list_builder.py +++ b/Lambdas/Scraping/prefix_list_builder.py @@ -1,3 +1,7 @@ +import json + +LIST_SIZE = 100 + wordlist = [] with open("nounlist.txt") as nounlist: for noun in nounlist: @@ -7,19 +11,23 @@ prefix_list = [] for word in wordlist: prefix_list.append(word[:min(len(word), 3)]) -short_list = [] -short_list2 = [] +word_lists = [] +for i in range(int(len(prefix_list) / LIST_SIZE)): + word_lists.append([]) + +current_list_len = 0 +current_list = 0 for prefix in prefix_list: prefix = prefix.strip() - if len(short_list) < 700: - if (len(short_list) == 0 or short_list[-1] != prefix): - short_list.append(prefix) - else: - if ((len(short_list2) == 0 or short_list2[-1] != prefix) and short_list[-1] != prefix): - short_list2.append(prefix) + if current_list_len >= LIST_SIZE: + if (word_lists[current_list][-1] != prefix): + current_list_len = 0 + current_list += 1 + if (current_list_len == 0 or word_lists[current_list][-1] != prefix): + word_lists[current_list].append(prefix) + current_list_len += 1 -with open("prefix_list_part1.txt", "w") as prefix_list_part1: - json.dump(short_list, prefix_list_part1) +for i in range(current_list + 1): + with open("prefix_list_part" + str(i + 1) + ".txt", "w") as prefix_list_part: + json.dump(word_lists[i], prefix_list_part) -with open("prefix_list_part2.txt", "w") as prefix_list_part2: - json.dump(short_list2, prefix_list_part2) \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part1.txt b/Lambdas/Scraping/prefix_list_part1.txt index ee83e0f..609d249 100644 --- a/Lambdas/Scraping/prefix_list_part1.txt +++ b/Lambdas/Scraping/prefix_list_part1.txt @@ -1 +1 @@ -["ATM", "CD", "SUV", "TV", "aar", "aba", "abb", "abd", "abi", "abn", "abo", "abr", "abs", "abu", "aca", "acc", "ace", "ach", "aci", "ack", "aco", "acq", "acr", "act", "acu", "ad", "ada", "add", "adj", "adm", "ado", "adr", "adu", "adv", "aff", "afo", "aft", "age", "agg", "agl", "ago", "agr", "aid", "aim", "air", "ala", "alb", "alc", "ald", "ale", "alf", "alg", "ali", "all", "alm", "alp", "alt", "alu", "ama", "amb", "ame", "amm", "amn", "amo", "amu", "ana", "anc", "and", "ane", "ang", "ani", "ank", "ann", "ano", "ans", "ant", "anx", "any", "apa", "ape", "apo", "app", "apr", "aps", "aqu", "arc", "are", "arg", "ari", "ark", "arm", "arr", "art", "asc", "ash", "asi", "asp", "ass", "ast", "asy", "ate", "ath", "atm", "ato", "atr", "att", "auc", "aud", "aun", "aut", "ava", "ave", "avo", "awa", "awe", "axi", "azi", "bab", "bac", "bad", "baf", "bag", "bai", "bak", "bal", "bam", "ban", "bao", "bar", "bas", "bat", "bay", "bea", "bec", "bed", "bee", "beg", "beh", "bei", "bel", "ben", "ber", "bes", "bet", "bev", "bey", "bia", "bib", "bic", "bid", "bif", "bij", "bik", "bil", "bin", "bio", "bip", "bir", "bis", "bit", "bla", "ble", "bli", "blo", "blu", "boa", "bob", "bod", "bog", "bol", "bom", "bon", "boo", "bor", "bos", "bot", "bou", "bow", "box", "boy", "bra", "bre", "bri", "bro", "bru", "bub", "buc", "bud", "buf", "bug", "bui", "bul", "bum", "bun", "bur", "bus", "but", "buy", "buz", "c-c", "cab", "cac", "cad", "caf", "cag", "cak", "cal", "cam", "can", "cap", "car", "cas", "cat", "cau", "cav", "cay", "cei", "cel", "cem", "cen", "cep", "cer", "ces", "cha", "che", "chi", "cho", "chr", "chu", "cic", "cig", "cil", "cin", "cir", "cit", "civ", "cla", "cle", "cli", "clo", "clu", "co-", "coa", "cob", "coc", "cod", "coe", "cof", "coh", "coi", "cok", "col", "com", "con", "coo", "cop", "cor", "cos", "cot", "cou", "cov", "cow", "coy", "cra", "cre", "cri", "cro", "cru", "cry", "cub", "cuc", "cue", "cuf", "cui", "cul", "cum", "cup", "cur", "cus", "cut", "cyc", "cyg", "cyl", "cym", "cyn", "cys", "cyt", "dad", "daf", "dag", "dah", "dai", "dam", "dan", "dar", "das", "dat", "dau", "daw", "day", "dea", "deb", "dec", "ded", "dee", "def", "deg", "del", "dem", "den", "deo", "dep", "der", "des", "det", "dev", "dew", "dho", "dia", "dib", "dic", "die", "dif", "dig", "dil", "dim", "din", "dio", "dip", "dir", "dis", "div", "doc", "doe", "dog", "doi", "dol", "dom", "don", "doo", "dor", "dos", "dot", "dou", "dow", "doz", "dra", "dre", "dri", "dro", "dru", "dry", "duc", "dud", "due", "duf", "dug", "dul", "dum", "dun", "dup", "dur", "dus", "dut", "dwa", "dwe", "dyn", "dys", "e-b", "e-m", "e-r", "eag", "ear", "eas", "eat", "eav", "ecc", "ech", "ecl", "eco", "ect", "ecu", "edd", "edg", "edi", "edu", "eel", "eff", "egg", "ego", "eic", "eje", "elb", "eld", "ele", "elf", "eli", "elk", "ell", "elm", "elo", "elv", "ema", "emb", "eme", "emi", "emo", "emp", "emu", "ena", "enc", "end", "ene", "enf", "eng", "eni", "enj", "enq", "enr", "ent", "env", "enz", "epa", "epe", "eph", "epi", "epo", "equ", "era", "ere", "ero", "err", "esc", "esp", "ess", "est", "ete", "eth", "eup", "eur", "eva", "eve", "evi", "evo", "ex-", "exa", "exc", "exe", "exh", "exi", "exo", "exp", "ext", "eye", "eyr", "fab", "fac", "fah", "fai", "fal", "fam", "fan", "far", "fas", "fat", "fau", "fav", "faw", "fax", "fea", "fed", "fee", "fel", "fem", "fen", "fer", "fes", "fet", "few", "fib", "fic", "fid", "fie", "fif", "fig", "fil", "fin", "fir", "fis", "fit", "fix", "fla", "fle", "fli", "flo", "flu", "fly", "foa", "fob", "foc", "fog", "fol", "fon", "foo", "for", "fou", "fow", "fox", "fra", "fre", "fri", "fro", "fru", "fry", "fuc", "fue", "fug", "ful", "fun", "fur", "fus", "fut", "gad", "gaf", "gai", "gal", "gam", "gan", "gap", "gar", "gas", "gat", "gau", "gav", "gaz", "gea", "gee", "gel", "gem", "gen", "geo", "ger", "ges", "gey", "ghe", "gho", "gia", "gif", "gig", "gin", "gir", "git", "gla", "gle", "gli", "glo", "glu", "gna", "gnu", "go-", "goa", "gob", "god", "gog", "goi", "gol", "gon", "goo", "gop", "gor", "gos", "gov", "gow", "gra", "gre", "gri", "gro", "gru", "gua", "gue", "gui", "gum", "gun", "gut", "guy", "gym", "gyn", "gyr", "hab", "hac", "hai", "hak", "hal", "ham", "han", "hap", "har", "has", "hat", "hau", "hav", "haw", "hay", "haz", "hea", "hec", "hed", "hee", "hei", "hel", "hem", "hen", "hep", "her", "hes", "het", "hex", "hey", "hic", "hid", "hie", "hig", "hik", "hil", "hin", "hip", "hir", "his", "hit", "hiv", "hob", "hoc", "hoe", "hog", "hol", "hom", "hon", "hoo", "hop", "hor", "hos", "hot", "hou", "hov", "how", "hub", "hug", "hul", "hum", "hun", "hur", "hus", "hut", "hya", "hyb", "hyd", "hye", "hyg", "hyp", "ice", "ici", "ico", "icy", "id", "ide", "idi", "igl", "ign", "ike", "ill", "ima", "imb", "imi", "imm", "imp", "in-", "ina", "inb", "inc", "ind", "ine", "inf", "ing", "inh", "ini", "inj", "ink", "inl", "inn", "inp", "inq", "ins", "int", "inv", "iri", "iro", "irr", "isc", "isl", "iso"] \ No newline at end of file +["ATM", "CD", "SUV", "TV", "aar", "aba", "abb", "abd", "abi", "abn", "abo", "abr", "abs", "abu", "aca", "acc", "ace", "ach", "aci", "ack", "aco", "acq", "acr", "act", "acu", "ad", "ada", "add", "adj", "adm", "ado", "adr", "adu", "adv", "aff", "afo", "aft", "age", "agg", "agl", "ago", "agr", "aid", "aim", "air", "ala", "alb", "alc", "ald", "ale", "alf", "alg", "ali", "all", "alm", "alp", "alt", "alu", "ama", "amb", "ame", "amm", "amn", "amo", "amu", "ana", "anc", "and", "ane", "ang", "ani", "ank", "ann", "ano", "ans", "ant", "anx", "any", "apa", "ape", "apo", "app", "apr", "aps", "aqu", "arc", "are", "arg", "ari", "ark", "arm", "arr", "art", "asc", "ash", "asi", "asp", "ass", "ast", "asy"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part10.txt b/Lambdas/Scraping/prefix_list_part10.txt new file mode 100644 index 0000000..dfb8ef0 --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part10.txt @@ -0,0 +1 @@ +["mow", "moz", "mud", "muf", "mug", "muk", "mul", "mur", "mus", "mut", "myc", "mys", "myt", "nai", "nam", "nan", "nap", "nar", "nas", "nat", "nav", "nec", "nee", "neg", "nei", "neo", "nep", "ner", "nes", "net", "neu", "new", "nex", "nib", "nic", "nie", "nig", "nin", "nit", "nob", "nod", "noi", "non", "noo", "nor", "nos", "not", "nou", "nov", "nuc", "nud", "nuk", "num", "nun", "nur", "nut", "nyl", "nym", "oak", "oar", "oas", "oat", "obe", "obi", "obj", "obl", "obo", "obs", "occ", "oce", "oct", "odo", "ody", "oeu", "off", "oil", "okr", "old", "ole", "oli", "ome", "omi", "omn", "onc", "oni", "onl", "ons", "ope", "oph", "opi", "opo", "opp", "opt", "ora", "orc", "ord", "ore", "org", "ori", "orn"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part11.txt b/Lambdas/Scraping/prefix_list_part11.txt new file mode 100644 index 0000000..c006589 --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part11.txt @@ -0,0 +1 @@ +["osm", "osp", "ost", "oth", "ott", "oun", "out", "ova", "ove", "owl", "own", "ox", "oxf", "oxy", "oys", "ozo", "pac", "pad", "pag", "pai", "paj", "pal", "pam", "pan", "pap", "par", "pas", "pat", "pau", "pav", "paw", "pay", "pea", "pec", "ped", "pee", "peg", "pel", "pen", "peo", "pep", "per", "pes", "pet", "pew", "pha", "phe", "phi", "pho", "phr", "phy", "pia", "pic", "pie", "pig", "pik", "pil", "pim", "pin", "pio", "pip", "pir", "pis", "pit", "piz", "pla", "ple", "pli", "plo", "plu", "ply", "pne", "poc", "pod", "poe", "poi", "pok", "pol", "pom", "pon", "poo", "pop", "por", "pos", "pot", "pou", "pov", "pow", "pra", "pre", "pri", "pro", "pru", "pse", "psy", "pta", "pub", "pud", "puf", "pug"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part12.txt b/Lambdas/Scraping/prefix_list_part12.txt new file mode 100644 index 0000000..55e69d8 --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part12.txt @@ -0,0 +1 @@ +["pul", "pum", "pun", "pup", "pur", "pus", "put", "puz", "pyr", "qua", "que", "qui", "quo", "rab", "rac", "rad", "raf", "rag", "rai", "rak", "ral", "ram", "ran", "rap", "ras", "rat", "rav", "raw", "ray", "raz", "rea", "reb", "rec", "red", "ree", "ref", "reg", "reh", "rei", "rej", "rel", "rem", "ren", "reo", "rep", "req", "res", "ret", "reu", "rev", "rew", "rhe", "rhi", "rhu", "rhy", "rib", "ric", "rid", "rif", "rig", "rim", "rin", "rio", "rip", "ris", "rit", "riv", "roa", "rob", "roc", "rod", "rol", "rom", "roo", "rop", "ros", "rot", "rou", "row", "rub", "ruc", "rud", "ruf", "rug", "rui", "rul", "rum", "run", "rus", "rut", "rye", "sab", "sac", "sad", "saf", "sag", "sai", "sak", "sal", "sam"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part13.txt b/Lambdas/Scraping/prefix_list_part13.txt new file mode 100644 index 0000000..b055e91 --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part13.txt @@ -0,0 +1 @@ +["san", "sar", "sas", "sat", "sau", "sav", "saw", "sax", "sca", "sce", "sch", "sci", "sco", "scr", "scu", "sea", "sec", "sed", "see", "seg", "sei", "sel", "sem", "sen", "sep", "seq", "ser", "ses", "set", "sev", "sew", "sex", "sha", "she", "shi", "sho", "shr", "shu", "sib", "sic", "sid", "sie", "sig", "sil", "sim", "sin", "sip", "sir", "sis", "sit", "siz", "ska", "ske", "ski", "sku", "sky", "sla", "sle", "sli", "slo", "slu", "sme", "smi", "smo", "smu", "sna", "sne", "sni", "sno", "snu", "soa", "soc", "sod", "sof", "soi", "sol", "som", "son", "soo", "sop", "sor", "sou", "sov", "sow", "soy", "spa", "spe", "sph", "spi", "spl", "spo", "spr", "spu", "spy", "squ", "sta", "ste", "sti", "sto", "str"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part14.txt b/Lambdas/Scraping/prefix_list_part14.txt new file mode 100644 index 0000000..a797044 --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part14.txt @@ -0,0 +1 @@ +["stu", "sty", "sub", "suc", "sue", "suf", "sug", "sui", "sul", "sum", "sun", "sup", "sur", "sus", "swa", "swe", "swi", "swo", "syc", "sym", "syn", "syr", "sys", "t-s", "tab", "tac", "tad", "tag", "tai", "tak", "tal", "tam", "tan", "tap", "tar", "tas", "tat", "tav", "tax", "tea", "tec", "tee", "tel", "tem", "ten", "tep", "ter", "tes", "tex", "tha", "the", "thi", "tho", "thr", "thu", "thy", "tia", "tic", "tid", "tie", "tig", "til", "tim", "tin", "tip", "tir", "tis", "tit", "toa", "tob", "tod", "toe", "tof", "tog", "toi", "tol", "tom", "ton", "too", "top", "toq", "tor", "tos", "tot", "tou", "tow", "toy", "tra", "tre", "tri", "tro", "tru", "try", "tsu", "tub", "tug", "tui", "tul", "tum", "tun"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part15.txt b/Lambdas/Scraping/prefix_list_part15.txt new file mode 100644 index 0000000..c918acd --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part15.txt @@ -0,0 +1 @@ +["tur", "tus", "tut", "tux", "twe", "twi", "typ", "uku", "ult", "umb", "unb", "unc", "und", "une", "uni", "upd", "upg", "upl", "upp", "ups", "upw", "urg", "urn", "usa", "use", "ush", "usu", "ute", "uti", "vac", "vag", "val", "vam", "van", "var", "vas", "vau", "vea", "vec", "veg", "veh", "vei", "vel", "ven", "ver", "ves", "vet", "via", "vib", "vic", "vid", "vie", "vig", "vil", "vin", "vio", "vir", "vis", "vit", "viv", "vix", "vod", "vog", "voi", "vol", "vom", "vot", "voy", "vul", "wad", "waf", "wag", "wai", "wak", "wal", "wam", "wan", "war", "was", "wat", "wav", "wax", "way", "wea", "web", "wed", "wee", "wei", "wel", "wes", "wet", "wha", "whe", "whi", "who", "wic", "wid", "wif", "wil", "win"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part16.txt b/Lambdas/Scraping/prefix_list_part16.txt new file mode 100644 index 0000000..73b4114 --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part16.txt @@ -0,0 +1 @@ +["wir", "wis", "wit", "wok", "wol", "wom", "won", "woo", "wor", "wou", "wra", "wre", "wri", "wro", "xyl", "yac", "yah", "yak", "yam", "yan", "yar", "yaw", "yea", "yel", "yes", "yew", "yin", "yog", "yok", "yol", "you", "yoy", "yur", "zam", "zeb", "zen", "zep", "zer", "zig", "zin", "zip", "zit", "zom", "zon", "zoo", "zuc"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part2.txt b/Lambdas/Scraping/prefix_list_part2.txt index 7bf12ad..dc7b122 100644 --- a/Lambdas/Scraping/prefix_list_part2.txt +++ b/Lambdas/Scraping/prefix_list_part2.txt @@ -1 +1 @@ -["iss", "ite", "iti", "ivo", "jac", "jad", "jag", "jai", "jal", "jam", "jar", "jas", "jaw", "jaz", "jea", "jee", "jel", "jer", "jet", "jew", "jic", "jif", "job", "joc", "jod", "joe", "jog", "joi", "jok", "jot", "jou", "joy", "jud", "jug", "jui", "jul", "jum", "jun", "jur", "jus", "jut", "kal", "kam", "kan", "kar", "kay", "kaz", "keb", "kee", "ken", "ket", "key", "kic", "kid", "kie", "kil", "kim", "kin", "kio", "kis", "kit", "kiw", "kne", "kni", "kno", "knu", "koa", "koh", "kum", "lab", "lac", "lad", "lag", "lak", "lam", "lan", "lap", "lar", "las", "lat", "lau", "lav", "law", "lay", "lea", "lec", "lee", "lef", "leg", "lei", "lem", "len", "leo", "lep", "les", "let", "lev", "lia", "lib", "lic", "lid", "lie", "lif", "lig", "lik", "lil", "lim", "lin", "lio", "lip", "liq", "lis", "lit", "liv", "liz", "lla", "loa", "lob", "loc", "lod", "lof", "log", "loi", "lol", "lon", "loo", "loq", "lor", "los", "lot", "lou", "lov", "lox", "loy", "luc", "lug", "lum", "lun", "lus", "lut", "lux", "lyc", "lye", "lym", "lyn", "lyo", "lyr", "lys", "mRN", "mac", "mad", "mae", "mag", "mai", "maj", "mak", "mal", "mam", "man", "map", "mar", "mas", "mat", "max", "may", "mea", "mec", "med", "mee", "mel", "mem", "men", "mer", "mes", "met", "mez", "mic", "mid", "mig", "mil", "mim", "min", "mir", "mis", "mit", "mix", "moa", "mob", "moc", "mod", "mol", "mom", "mon", "moo", "mop", "mor", "mos", "mot", "mou", "mov", "mow", "moz", "mud", "muf", "mug", "muk", "mul", "mur", "mus", "mut", "myc", "mys", "myt", "nai", "nam", "nan", "nap", "nar", "nas", "nat", "nav", "nec", "nee", "neg", "nei", "neo", "nep", "ner", "nes", "net", "neu", "new", "nex", "nib", "nic", "nie", "nig", "nin", "nit", "nob", "nod", "noi", "non", "noo", "nor", "nos", "not", "nou", "nov", "nuc", "nud", "nuk", "num", "nun", "nur", "nut", "nyl", "nym", "oak", "oar", "oas", "oat", "obe", "obi", "obj", "obl", "obo", "obs", "occ", "oce", "oct", "odo", "ody", "oeu", "off", "oil", "okr", "old", "ole", "oli", "ome", "omi", "omn", "onc", "oni", "onl", "ons", "ope", "oph", "opi", "opo", "opp", "opt", "ora", "orc", "ord", "ore", "org", "ori", "orn", "osm", "osp", "ost", "oth", "ott", "oun", "out", "ova", "ove", "owl", "own", "ox", "oxf", "oxy", "oys", "ozo", "pac", "pad", "pag", "pai", "paj", "pal", "pam", "pan", "pap", "par", "pas", "pat", "pau", "pav", "paw", "pay", "pea", "pec", "ped", "pee", "peg", "pel", "pen", "peo", "pep", "per", "pes", "pet", "pew", "pha", "phe", "phi", "pho", "phr", "phy", "pia", "pic", "pie", "pig", "pik", "pil", "pim", "pin", "pio", "pip", "pir", "pis", "pit", "piz", "pla", "ple", "pli", "plo", "plu", "ply", "pne", "poc", "pod", "poe", "poi", "pok", "pol", "pom", "pon", "poo", "pop", "por", "pos", "pot", "pou", "pov", "pow", "pra", "pre", "pri", "pro", "pru", "pse", "psy", "pta", "pub", "pud", "puf", "pug", "pul", "pum", "pun", "pup", "pur", "pus", "put", "puz", "pyr", "qua", "que", "qui", "quo", "rab", "rac", "rad", "raf", "rag", "rai", "rak", "ral", "ram", "ran", "rap", "ras", "rat", "rav", "raw", "ray", "raz", "rea", "reb", "rec", "red", "ree", "ref", "reg", "reh", "rei", "rej", "rel", "rem", "ren", "reo", "rep", "req", "res", "ret", "reu", "rev", "rew", "rhe", "rhi", "rhu", "rhy", "rib", "ric", "rid", "rif", "rig", "rim", "rin", "rio", "rip", "ris", "rit", "riv", "roa", "rob", "roc", "rod", "rol", "rom", "roo", "rop", "ros", "rot", "rou", "row", "rub", "ruc", "rud", "ruf", "rug", "rui", "rul", "rum", "run", "rus", "rut", "rye", "sab", "sac", "sad", "saf", "sag", "sai", "sak", "sal", "sam", "san", "sar", "sas", "sat", "sau", "sav", "saw", "sax", "sca", "sce", "sch", "sci", "sco", "scr", "scu", "sea", "sec", "sed", "see", "seg", "sei", "sel", "sem", "sen", "sep", "seq", "ser", "ses", "set", "sev", "sew", "sex", "sha", "she", "shi", "sho", "shr", "shu", "sib", "sic", "sid", "sie", "sig", "sil", "sim", "sin", "sip", "sir", "sis", "sit", "siz", "ska", "ske", "ski", "sku", "sky", "sla", "sle", "sli", "slo", "slu", "sme", "smi", "smo", "smu", "sna", "sne", "sni", "sno", "snu", "soa", "soc", "sod", "sof", "soi", "sol", "som", "son", "soo", "sop", "sor", "sou", "sov", "sow", "soy", "spa", "spe", "sph", "spi", "spl", "spo", "spr", "spu", "spy", "squ", "sta", "ste", "sti", "sto", "str", "stu", "sty", "sub", "suc", "sue", "suf", "sug", "sui", "sul", "sum", "sun", "sup", "sur", "sus", "swa", "swe", "swi", "swo", "syc", "sym", "syn", "syr", "sys", "t-s", "tab", "tac", "tad", "tag", "tai", "tak", "tal", "tam", "tan", "tap", "tar", "tas", "tat", "tav", "tax", "tea", "tec", "tee", "tel", "tem", "ten", "tep", "ter", "tes", "tex", "tha", "the", "thi", "tho", "thr", "thu", "thy", "tia", "tic", "tid", "tie", "tig", "til", "tim", "tin", "tip", "tir", "tis", "tit", "toa", "tob", "tod", "toe", "tof", "tog", "toi", "tol", "tom", "ton", "too", "top", "toq", "tor", "tos", "tot", "tou", "tow", "toy", "tra", "tre", "tri", "tro", "tru", "try", "tsu", "tub", "tug", "tui", "tul", "tum", "tun", "tur", "tus", "tut", "tux", "twe", "twi", "typ", "uku", "ult", "umb", "unb", "unc", "und", "une", "uni", "upd", "upg", "upl", "upp", "ups", "upw", "urg", "urn", "usa", "use", "ush", "usu", "ute", "uti", "vac", "vag", "val", "vam", "van", "var", "vas", "vau", "vea", "vec", "veg", "veh", "vei", "vel", "ven", "ver", "ves", "vet", "via", "vib", "vic", "vid", "vie", "vig", "vil", "vin", "vio", "vir", "vis", "vit", "viv", "vix", "vod", "vog", "voi", "vol", "vom", "vot", "voy", "vul", "wad", "waf", "wag", "wai", "wak", "wal", "wam", "wan", "war", "was", "wat", "wav", "wax", "way", "wea", "web", "wed", "wee", "wei", "wel", "wes", "wet", "wha", "whe", "whi", "who", "wic", "wid", "wif", "wil", "win", "wir", "wis", "wit", "wok", "wol", "wom", "won", "woo", "wor", "wou", "wra", "wre", "wri", "wro", "xyl", "yac", "yah", "yak", "yam", "yan", "yar", "yaw", "yea", "yel", "yes", "yew", "yin", "yog", "yok", "yol", "you", "yoy", "yur", "zam", "zeb", "zen", "zep", "zer", "zig", "zin", "zip", "zit", "zom", "zon", "zoo", "zuc"] \ No newline at end of file +["ate", "ath", "atm", "ato", "atr", "att", "auc", "aud", "aun", "aut", "ava", "ave", "avo", "awa", "awe", "axi", "azi", "bab", "bac", "bad", "baf", "bag", "bai", "bak", "bal", "bam", "ban", "bao", "bar", "bas", "bat", "bay", "bea", "bec", "bed", "bee", "beg", "beh", "bei", "bel", "ben", "ber", "bes", "bet", "bev", "bey", "bia", "bib", "bic", "bid", "bif", "bij", "bik", "bil", "bin", "bio", "bip", "bir", "bis", "bit", "bla", "ble", "bli", "blo", "blu", "boa", "bob", "bod", "bog", "bol", "bom", "bon", "boo", "bor", "bos", "bot", "bou", "bow", "box", "boy", "bra", "bre", "bri", "bro", "bru", "bub", "buc", "bud", "buf", "bug", "bui", "bul", "bum", "bun", "bur", "bus", "but", "buy", "buz", "c-c"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part3.txt b/Lambdas/Scraping/prefix_list_part3.txt new file mode 100644 index 0000000..9921254 --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part3.txt @@ -0,0 +1 @@ +["cab", "cac", "cad", "caf", "cag", "cak", "cal", "cam", "can", "cap", "car", "cas", "cat", "cau", "cav", "cay", "cei", "cel", "cem", "cen", "cep", "cer", "ces", "cha", "che", "chi", "cho", "chr", "chu", "cic", "cig", "cil", "cin", "cir", "cit", "civ", "cla", "cle", "cli", "clo", "clu", "co-", "coa", "cob", "coc", "cod", "coe", "cof", "coh", "coi", "cok", "col", "com", "con", "coo", "cop", "cor", "cos", "cot", "cou", "cov", "cow", "coy", "cra", "cre", "cri", "cro", "cru", "cry", "cub", "cuc", "cue", "cuf", "cui", "cul", "cum", "cup", "cur", "cus", "cut", "cyc", "cyg", "cyl", "cym", "cyn", "cys", "cyt", "dad", "daf", "dag", "dah", "dai", "dam", "dan", "dar", "das", "dat", "dau", "daw", "day"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part4.txt b/Lambdas/Scraping/prefix_list_part4.txt new file mode 100644 index 0000000..9b6ef4e --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part4.txt @@ -0,0 +1 @@ +["dea", "deb", "dec", "ded", "dee", "def", "deg", "del", "dem", "den", "deo", "dep", "der", "des", "det", "dev", "dew", "dho", "dia", "dib", "dic", "die", "dif", "dig", "dil", "dim", "din", "dio", "dip", "dir", "dis", "div", "doc", "doe", "dog", "doi", "dol", "dom", "don", "doo", "dor", "dos", "dot", "dou", "dow", "doz", "dra", "dre", "dri", "dro", "dru", "dry", "duc", "dud", "due", "duf", "dug", "dul", "dum", "dun", "dup", "dur", "dus", "dut", "dwa", "dwe", "dyn", "dys", "e-b", "e-m", "e-r", "eag", "ear", "eas", "eat", "eav", "ecc", "ech", "ecl", "eco", "ect", "ecu", "edd", "edg", "edi", "edu", "eel", "eff", "egg", "ego", "eic", "eje", "elb", "eld", "ele", "elf", "eli", "elk", "ell", "elm"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part5.txt b/Lambdas/Scraping/prefix_list_part5.txt new file mode 100644 index 0000000..d484781 --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part5.txt @@ -0,0 +1 @@ +["elo", "elv", "ema", "emb", "eme", "emi", "emo", "emp", "emu", "ena", "enc", "end", "ene", "enf", "eng", "eni", "enj", "enq", "enr", "ent", "env", "enz", "epa", "epe", "eph", "epi", "epo", "equ", "era", "ere", "ero", "err", "esc", "esp", "ess", "est", "ete", "eth", "eup", "eur", "eva", "eve", "evi", "evo", "ex-", "exa", "exc", "exe", "exh", "exi", "exo", "exp", "ext", "eye", "eyr", "fab", "fac", "fah", "fai", "fal", "fam", "fan", "far", "fas", "fat", "fau", "fav", "faw", "fax", "fea", "fed", "fee", "fel", "fem", "fen", "fer", "fes", "fet", "few", "fib", "fic", "fid", "fie", "fif", "fig", "fil", "fin", "fir", "fis", "fit", "fix", "fla", "fle", "fli", "flo", "flu", "fly", "foa", "fob", "foc"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part6.txt b/Lambdas/Scraping/prefix_list_part6.txt new file mode 100644 index 0000000..ef04150 --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part6.txt @@ -0,0 +1 @@ +["fog", "fol", "fon", "foo", "for", "fou", "fow", "fox", "fra", "fre", "fri", "fro", "fru", "fry", "fuc", "fue", "fug", "ful", "fun", "fur", "fus", "fut", "gad", "gaf", "gai", "gal", "gam", "gan", "gap", "gar", "gas", "gat", "gau", "gav", "gaz", "gea", "gee", "gel", "gem", "gen", "geo", "ger", "ges", "gey", "ghe", "gho", "gia", "gif", "gig", "gin", "gir", "git", "gla", "gle", "gli", "glo", "glu", "gna", "gnu", "go-", "goa", "gob", "god", "gog", "goi", "gol", "gon", "goo", "gop", "gor", "gos", "gov", "gow", "gra", "gre", "gri", "gro", "gru", "gua", "gue", "gui", "gum", "gun", "gut", "guy", "gym", "gyn", "gyr", "hab", "hac", "hai", "hak", "hal", "ham", "han", "hap", "har", "has", "hat", "hau"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part7.txt b/Lambdas/Scraping/prefix_list_part7.txt new file mode 100644 index 0000000..214eda8 --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part7.txt @@ -0,0 +1 @@ +["hav", "haw", "hay", "haz", "hea", "hec", "hed", "hee", "hei", "hel", "hem", "hen", "hep", "her", "hes", "het", "hex", "hey", "hic", "hid", "hie", "hig", "hik", "hil", "hin", "hip", "hir", "his", "hit", "hiv", "hob", "hoc", "hoe", "hog", "hol", "hom", "hon", "hoo", "hop", "hor", "hos", "hot", "hou", "hov", "how", "hub", "hug", "hul", "hum", "hun", "hur", "hus", "hut", "hya", "hyb", "hyd", "hye", "hyg", "hyp", "ice", "ici", "ico", "icy", "id", "ide", "idi", "igl", "ign", "ike", "ill", "ima", "imb", "imi", "imm", "imp", "in-", "ina", "inb", "inc", "ind", "ine", "inf", "ing", "inh", "ini", "inj", "ink", "inl", "inn", "inp", "inq", "ins", "int", "inv", "iri", "iro", "irr", "isc", "isl", "iso"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part8.txt b/Lambdas/Scraping/prefix_list_part8.txt new file mode 100644 index 0000000..dee89f0 --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part8.txt @@ -0,0 +1 @@ +["iss", "ite", "iti", "ivo", "jac", "jad", "jag", "jai", "jal", "jam", "jar", "jas", "jaw", "jaz", "jea", "jee", "jel", "jer", "jet", "jew", "jic", "jif", "job", "joc", "jod", "joe", "jog", "joi", "jok", "jot", "jou", "joy", "jud", "jug", "jui", "jul", "jum", "jun", "jur", "jus", "jut", "kal", "kam", "kan", "kar", "kay", "kaz", "keb", "kee", "ken", "ket", "key", "kic", "kid", "kie", "kil", "kim", "kin", "kio", "kis", "kit", "kiw", "kne", "kni", "kno", "knu", "koa", "koh", "kum", "lab", "lac", "lad", "lag", "lak", "lam", "lan", "lap", "lar", "las", "lat", "lau", "lav", "law", "lay", "lea", "lec", "lee", "lef", "leg", "lei", "lem", "len", "leo", "lep", "les", "let", "lev", "lia", "lib", "lic"] \ No newline at end of file diff --git a/Lambdas/Scraping/prefix_list_part9.txt b/Lambdas/Scraping/prefix_list_part9.txt new file mode 100644 index 0000000..3dddc56 --- /dev/null +++ b/Lambdas/Scraping/prefix_list_part9.txt @@ -0,0 +1 @@ +["lid", "lie", "lif", "lig", "lik", "lil", "lim", "lin", "lio", "lip", "liq", "lis", "lit", "liv", "liz", "lla", "loa", "lob", "loc", "lod", "lof", "log", "loi", "lol", "lon", "loo", "loq", "lor", "los", "lot", "lou", "lov", "lox", "loy", "luc", "lug", "lum", "lun", "lus", "lut", "lux", "lyc", "lye", "lym", "lyn", "lyo", "lyr", "lys", "mRN", "mac", "mad", "mae", "mag", "mai", "maj", "mak", "mal", "mam", "man", "map", "mar", "mas", "mat", "max", "may", "mea", "mec", "med", "mee", "mel", "mem", "men", "mer", "mes", "met", "mez", "mic", "mid", "mig", "mil", "mim", "min", "mir", "mis", "mit", "mix", "moa", "mob", "moc", "mod", "mol", "mom", "mon", "moo", "mop", "mor", "mos", "mot", "mou", "mov"] \ No newline at end of file diff --git a/Lambdas/Scraping/runOrchestrator.py b/Lambdas/Scraping/runOrchestrator.py index b4d8b7f..b7436ab 100644 --- a/Lambdas/Scraping/runOrchestrator.py +++ b/Lambdas/Scraping/runOrchestrator.py @@ -1,11 +1,15 @@ import json import boto3 +import time + def lambda_handler(event, context): - with open("words.txt") as words_file: + list_num = event["list_num"] + with open("prefix_list_part" + str(list_num) + ".txt") as words_file: words = json.load(words_file) print(words) for word in words: + time.sleep(6) client = boto3.client('lambda') response = client.invoke( FunctionName='KohlsScraper', @@ -13,7 +17,16 @@ def lambda_handler(event, context): LogType="None", Payload= """{"toScrape": \"""" + word + "\"}" ) + if (event["linked"]): + if list_num < 16: + time.sleep(200) + client.invoke( + FunctionName='RunOrchestrator', + InvocationType="Event", + LogType="None", + Payload= "{\"list_num\": "+ str(list_num + 1) + ",\"linked\": true}" + ) return { 'statusCode': 200, 'body': json.dumps('Hello from Lambda!') - } \ No newline at end of file + }