preformence improvement
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
.vscode/
|
.vscode/
|
||||||
venv/
|
venv/
|
||||||
|
ignore/
|
@@ -76,7 +76,10 @@ def do_action_now(index: int):
|
|||||||
files = list(SOURCES[index])
|
files = list(SOURCES[index])
|
||||||
for s in SOURCES[index]:
|
for s in SOURCES[index]:
|
||||||
if SOURCES[index][s]:
|
if SOURCES[index][s]:
|
||||||
files[files.index(s)] = urllib3.PoolManager().request("GET", SOURCES[index][s]).data
|
if not os.path.exists(f"ignore/{files.index(s):04}.jpg"):
|
||||||
|
with open(f"ignore/{files.index(s):04}.jpg","wb") as F:
|
||||||
|
F.write(urllib3.PoolManager().request("GET", SOURCES[index][s]).data)
|
||||||
|
# files[files.index(s)] = urllib3.PoolManager().request("GET", SOURCES[index][s]).data
|
||||||
return files
|
return files
|
||||||
# def check_and_act(index: int,last):
|
# def check_and_act(index: int,last):
|
||||||
|
|
||||||
@@ -110,15 +113,15 @@ def act_now(index: int, path: str = None):
|
|||||||
url_now = url_now[:url_now.find("#")+1] + save_first
|
url_now = url_now[:url_now.find("#")+1] + save_first
|
||||||
if SOURCES[index][last] and "" in SOURCES[index].values():
|
if SOURCES[index][last] and "" in SOURCES[index].values():
|
||||||
ACTS[index]._driver.get(url_now)
|
ACTS[index]._driver.get(url_now)
|
||||||
pages = do_action_now(index)
|
do_action_now(index)
|
||||||
SOURCES[index][last] = ""
|
SOURCES[index][last] = ""
|
||||||
else:
|
else:
|
||||||
pages = do_action_now(index)
|
do_action_now(index)
|
||||||
if SOURCES[index] and "" not in SOURCES[index].values():
|
if SOURCES[index] and "" not in SOURCES[index].values():
|
||||||
couters += 1
|
couters += 1
|
||||||
pathus = f'{path}/{name}.pdf' if path else f"ignore/{name}/{name}.pdf"
|
pathus = f'{path}/{name}.pdf' if path else f"ignore/{name}/{name}.pdf"
|
||||||
with open(pathus, "wb") as file:
|
with open(pathus, "wb") as file:
|
||||||
file.write(img2pdf.convert(pages))
|
file.write(img2pdf.convert(glob.glob(f"ignore/{name}/*jpg")))
|
||||||
ACTS[index]._driver.quit()
|
ACTS[index]._driver.quit()
|
||||||
remove_text(OLD_REMOVE[index])
|
remove_text(OLD_REMOVE[index])
|
||||||
treads -= 1
|
treads -= 1
|
||||||
|
Reference in New Issue
Block a user