mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
Minor refactoring
This commit is contained in:
@@ -2,23 +2,18 @@
|
||||
Copyright (C) 2022 Sebastian Thomschke and contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
import atexit, copy, getopt, importlib.metadata, json, logging, os, signal, sys, textwrap, time, urllib
|
||||
import re
|
||||
import shutil
|
||||
import atexit, copy, getopt, importlib.metadata, json, logging, os, re, signal, shutil, sys, textwrap, time, urllib
|
||||
from collections.abc import Iterable
|
||||
from datetime import datetime
|
||||
from logging.handlers import RotatingFileHandler
|
||||
from typing import Any, Final
|
||||
from urllib import request
|
||||
from wcmatch import glob
|
||||
|
||||
from overrides import overrides
|
||||
from ruamel.yaml import YAML
|
||||
from selenium.common.exceptions import NoSuchElementException, TimeoutException, WebDriverException, \
|
||||
ElementClickInterceptedException
|
||||
from selenium.common.exceptions import ElementClickInterceptedException, NoSuchElementException, TimeoutException, WebDriverException
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
|
||||
from . import utils, resources, extract # pylint: disable=W0406
|
||||
from .utils import abspath, apply_defaults, ensure, is_frozen, pause, pluralize, safe_get, parse_datetime
|
||||
@@ -365,7 +360,6 @@ class KleinanzeigenBot(SeleniumMixin):
|
||||
self.handle_captcha_if_present("login-recaptcha", "but DON'T click 'Einloggen'.")
|
||||
|
||||
self.web_click(By.ID, "login-submit")
|
||||
|
||||
pause(800, 3000)
|
||||
|
||||
def handle_captcha_if_present(self, captcha_element_id:str, msg:str) -> None:
|
||||
@@ -670,7 +664,7 @@ class KleinanzeigenBot(SeleniumMixin):
|
||||
self.web_input(By.XPATH, '//*[@id="site-search-query"]', str(id_))
|
||||
# navigate to ad page and wait
|
||||
submit_button = self.webdriver.find_element(By.XPATH, '//*[@id="site-search-submit"]')
|
||||
WebDriverWait(self.webdriver, 15).until(EC.element_to_be_clickable(submit_button))
|
||||
self.web_await(EC.element_to_be_clickable(submit_button), 15)
|
||||
try:
|
||||
submit_button.click()
|
||||
except ElementClickInterceptedException: # sometimes: special banner might pop up and intercept
|
||||
@@ -734,7 +728,7 @@ class KleinanzeigenBot(SeleniumMixin):
|
||||
file_ending = current_img_url.split('.')[-1].lower()
|
||||
img_path = directory + '/' + img_fn_prefix + str(img_nr) + '.' + file_ending
|
||||
if current_img_url.startswith('https'): # verify https (for Bandit linter)
|
||||
request.urlretrieve(current_img_url, img_path) # nosec B310
|
||||
urllib.request.urlretrieve(current_img_url, img_path) # nosec B310
|
||||
dl_counter += 1
|
||||
img_paths.append(img_path.split('/')[-1])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user