Compare commits
4 Commits
b509a852f1
...
b560ff1c1c
Author | SHA1 | Date | |
---|---|---|---|
b560ff1c1c | |||
aa12ff726e | |||
9da95ee850 | |||
a8136a7ff4 |
@ -7,14 +7,14 @@ hrefs = []
|
||||
|
||||
|
||||
def main():
|
||||
directory = "dist"
|
||||
file_path = os.path.join(directory, "data.json")
|
||||
directory = os.path.dirname(os.path.realpath(__file__))
|
||||
file_path = os.path.join(directory, "dist", "data.json")
|
||||
scrap(urls[0])
|
||||
|
||||
data = []
|
||||
|
||||
try:
|
||||
os.mkdir("dist")
|
||||
os.mkdir(os.path.join(directory, "dist"))
|
||||
except FileExistsError:
|
||||
pass
|
||||
with open(file_path, "w", encoding="utf-8") as file:
|
||||
|
@ -1,23 +1,9 @@
|
||||
import os
|
||||
from run_command import run_command
|
||||
|
||||
|
||||
def get_path():
|
||||
pwd = run_command("pwd")
|
||||
splitted = pwd.split("/")
|
||||
splitted[-1] = splitted[-1].replace("\n", "")
|
||||
|
||||
if splitted.count("webscraper") > 1 and "webscraper" in splitted:
|
||||
for i in range(len(splitted) - 1, -1, -1):
|
||||
potential_path = "/".join(splitted[: i + 1])
|
||||
if "webscraper" in potential_path:
|
||||
script_path = f"{potential_path}/scripts"
|
||||
if os.path.isdir(script_path):
|
||||
return potential_path
|
||||
else:
|
||||
return "This is not a valid webscraper project."
|
||||
else:
|
||||
path = "/".join(splitted[: splitted.index("webscraper") + 1])
|
||||
current_path = os.path.dirname(os.path.abspath(__file__))
|
||||
path = "/".join(current_path.split("/")[:-1])
|
||||
return path
|
||||
|
||||
|
||||
|
@ -19,15 +19,23 @@ def clearCondition(command: str) -> bool:
|
||||
return command in ["c", "clear", "cls"]
|
||||
|
||||
|
||||
def clearScreen():
|
||||
print(run_command("clear"))
|
||||
return None
|
||||
|
||||
|
||||
def systemCommand(command: str) -> str:
|
||||
words = command[1:].split()
|
||||
if words[0] == "":
|
||||
return "Command not found. Write 'h' for help."
|
||||
try:
|
||||
print(
|
||||
run_command(
|
||||
f'docker exec -it webscraper {" ".join(words)}',
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
return None
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ def prompt():
|
||||
print(help_list())
|
||||
continue
|
||||
if clearCondition(command):
|
||||
run_command("clear")
|
||||
clearScreen()
|
||||
continue
|
||||
if command.startswith("$"):
|
||||
systemCommand(command)
|
||||
|
Loading…
Reference in New Issue
Block a user