-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed file structure and added dynamic input data
Changed the structure to be a bit more organized and updated all files to run from main.py. Also made it so everytime the grabber runs it grabs the new inputdata.txt file from github to elimate updating the entire docker file everytime I need to add a link. Also allows for easier pull requests to be made to the input data file.
- Loading branch information
Showing
11 changed files
with
104 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SELENIUMCLIENT=yourseleniumclient | ||
SEARCHCLIENT=yourmeilisearchclient | ||
SEARCHAPIKEY=yourmeilisearchclientapikey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,57 @@ | ||
import json | ||
import random | ||
import string | ||
def listToString(s): | ||
# initialize an empty string | ||
str1 = "" | ||
count=0 | ||
# traverse in the string | ||
for ele in s: | ||
str1 += ele | ||
count+=1 | ||
if count==len(s): | ||
continue | ||
else: | ||
str1+=" " | ||
# return string | ||
return str1 | ||
input_file = 'outputcleaned.json' # input file | ||
output_file = 'outputsearchready.json' | ||
# Opening JSON file | ||
f = open(input_file) | ||
N=10 # ID length | ||
count= 0 | ||
dic= {} # to store overal output | ||
data = json.load(f) | ||
for k in data.keys(): | ||
key = k | ||
lst= [] | ||
count+=1 | ||
for sub_k in data[k]: # access each entry | ||
ID= ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(N)) # generating IDs of N length | ||
j = sub_k.split("/")[-1] | ||
if j=='': | ||
j= sub_k.split("/")[-2] | ||
name=None | ||
if "-" in j: | ||
name = j.split("-") | ||
else: | ||
name= j.split("_") | ||
name = [nam.title() for nam in name ] | ||
name = listToString(name) | ||
# print(sub_k.replace("https://",""), j, name) | ||
lst.append({"id":ID, "basename":name.replace("%",""),"link":sub_k.replace("https://","")}) | ||
dic[key] = lst | ||
# comment next two lines, if you want output for all objects. This 'IF' is just for three objects to check output | ||
#if count==3: | ||
# break | ||
with open(output_file, "w") as outfile: | ||
json.dump(dic, outfile) | ||
json_file = open("outputsearchready.json") | ||
file = json.load(json_file) | ||
data = file.pop('marked') | ||
with open("outputsearchready.json", "w", encoding="utf-8") as file:#dumps to new json file to be used in totable.py | ||
file.write( | ||
json.dumps(data) | ||
) | ||
import json | ||
import random | ||
import string | ||
def listToString(s): | ||
# initialize an empty string | ||
str1 = "" | ||
count=0 | ||
# traverse in the string | ||
for ele in s: | ||
str1 += ele | ||
count+=1 | ||
if count==len(s): | ||
continue | ||
else: | ||
str1+=" " | ||
# return string | ||
return str1 | ||
input_file = './components/outputcleaned.json' # input file | ||
output_file = './components/outputsearchready.json' | ||
# Opening JSON file | ||
f = open(input_file) | ||
N=10 # ID length | ||
count= 0 | ||
dic= {} # to store overal output | ||
data = json.load(f) | ||
for k in data.keys(): | ||
key = k | ||
lst= [] | ||
count+=1 | ||
for sub_k in data[k]: # access each entry | ||
ID= ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(N)) # generating IDs of N length | ||
j = sub_k.split("/")[-1] | ||
if j=='': | ||
j= sub_k.split("/")[-2] | ||
name=None | ||
if "-" in j: | ||
name = j.split("-") | ||
else: | ||
name= j.split("_") | ||
name = [nam.title() for nam in name ] | ||
name = listToString(name) | ||
# print(sub_k.replace("https://",""), j, name) | ||
lst.append({"id":ID, "basename":name.replace("%",""),"link":sub_k.replace("https://","")}) | ||
dic[key] = lst | ||
# comment next two lines, if you want output for all objects. This 'IF' is just for three objects to check output | ||
#if count==3: | ||
# break | ||
with open(output_file, "w") as outfile: | ||
json.dump(dic, outfile) | ||
json_file = open("./components/outputsearchready.json") | ||
file = json.load(json_file) | ||
data = file.pop('marked') | ||
with open("./components/outputsearchready.json", "w", encoding="utf-8") as file:#dumps to new json file to be used in totable.py | ||
file.write( | ||
json.dumps(data) | ||
) | ||
import sendtosearch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import meilisearch | ||
import json | ||
import os | ||
import decouple | ||
from decouple import config | ||
# | ||
SEARCHCLIENT = config('SEARCHCLIENT') | ||
SEARCHAPIKEY = config('SEARCHAPIKEY') | ||
# | ||
#client = meilisearch.Client('serverlocation', 'apikey') | ||
client = meilisearch.Client(SEARCHCLIENT, SEARCHAPIKEY) | ||
json_file = open('./components/outputsearchready.json') | ||
games = json.load(json_file) | ||
client.delete_index('games') #deletes previous index due to the way meilisearch does indexes, it adds on top of, and updating doesn't work very well, so a good ole delete and create works fine. | ||
client.index('games').add_documents(games) | ||
print('finished entire process.') |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#Welcome to Rezi! | ||
# ____ _ | ||
# / __ \___ ____ (_) | ||
# / /_/ / _ \/_ / / / | ||
# / _, _/ __/ / /_/ / | ||
#/_/ |_|\___/ /___/_/ | ||
#Rezi was written in Python 3.9.6 on Selenium. | ||
import sys | ||
sys.path.append('./components') | ||
import grabber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
beautifulsoup4 == 4.10.0 | ||
selenium == 4.1.0 | ||
undetected-chromedriver == 3.0.6 | ||
requests-html == 0.10.0 | ||
output == 1.0.1 | ||
json2table | ||
pysftp | ||
requests | ||
output | ||
meilisearch | ||
pysftp | ||
python-decouple |
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.