Added sites subdirectory and reading function

This commit is contained in:
Lukas 2020-10-31 16:12:01 +01:00
parent d918d874f4
commit 19a237326b
4 changed files with 43 additions and 3 deletions

33
main.py
View File

@ -1,21 +1,48 @@
import src.monitor as monitor
import src.tools as tools
import src.monitor as monitor
import src.proxy as proxy
import os
import glob
import json
from colorama import Style, Fore, init
def readsites(p=None):
dod = {}
if p:
sitedir = p
else:
rootdir = os.path.dirname(os.path.abspath(__file__))
sitedir = rootdir + r"\sites"
for sitefile in glob.glob(sitedir + r"\*.json"):
sfn = os.path.basename(sitefile)
site, ext = os.path.splitext(sfn)
print(f"Parsing {sfn}")
with open(sitefile, 'r') as f:
data = json.load(f)
dod[site] = data
print(dod)
if __name__ == "__main__":
url = "https://www.nike.com/de/launch?s=upcoming"
num_monitors = 10
# Initialize Colorama
init(autoreset=True)
readsites()
tools.clear()
print(f"Creating {num_monitors} new Monitors...\n{tools.spacer}")
for i in range(0, num_monitors):
mon = monitor.Monitor()
mon.name = f"Monitor {i}"
mon.url = url
mon.url = "test"
print(f"{Fore.MAGENTA}{mon.name}{Style.RESET_ALL} |"
f" {tools.keyword('URL')}({mon.url}) {tools.keyword('PROXY')}({mon.proxy})")
print(tools.spacer)

3
sites/nike.json Normal file
View File

@ -0,0 +1,3 @@
{
"url": "https://www.nike.com/de/launch?s=upcoming"
}

View File

@ -1,6 +1,7 @@
class Monitor:
def __init__(self):
self.url = None
self.name = None
self.proxy = None

9
src/proxy.py Normal file
View File

@ -0,0 +1,9 @@
class Proxy:
def __init__(self):
self.name = None
self.url = None
self.usr = None
self.pwd = None
self.status = None