bcpkgfox 0.15.30__py3-none-any.whl → 0.17.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bcpkgfox/__init__.py +79 -26
- bcpkgfox/clean.py +257 -0
- bcpkgfox/cli.py +465 -138
- bcpkgfox/find_elements.py +33 -8
- bcpkgfox/get_driver.py +33 -14
- bcpkgfox/invoke_api.py +386 -88
- bcpkgfox/system.py +42 -9
- {bcpkgfox-0.15.30.dist-info → bcpkgfox-0.17.7.dist-info}/METADATA +20 -4
- bcpkgfox-0.17.7.dist-info/RECORD +12 -0
- {bcpkgfox-0.15.30.dist-info → bcpkgfox-0.17.7.dist-info}/WHEEL +1 -1
- bcpkgfox-0.17.7.dist-info/entry_points.txt +22 -0
- bcpkgfox/cli 2.py +0 -536
- bcpkgfox/cli copy 2.py +0 -237
- bcpkgfox/cli copy.py +0 -306
- bcpkgfox/cli2.py +0 -303
- bcpkgfox/dasdad.py +0 -68
- bcpkgfox/exec_file copy 2.py +0 -100
- bcpkgfox/exec_file copy.py +0 -99
- bcpkgfox/exec_file.py +0 -100
- bcpkgfox-0.15.30.dist-info/RECORD +0 -19
- bcpkgfox-0.15.30.dist-info/entry_points.txt +0 -2
- {bcpkgfox-0.15.30.dist-info → bcpkgfox-0.17.7.dist-info}/top_level.txt +0 -0
bcpkgfox/find_elements.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from selenium.common.exceptions import ElementClickInterceptedException
|
|
1
2
|
from selenium.webdriver.support import expected_conditions as EC
|
|
2
3
|
from selenium.webdriver.remote.webelement import WebElement
|
|
3
4
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
@@ -17,6 +18,35 @@ class Elements:
|
|
|
17
18
|
def __init__(self, driver):
|
|
18
19
|
self.driver = driver
|
|
19
20
|
|
|
21
|
+
def click_with_wait(
|
|
22
|
+
self,
|
|
23
|
+
by: str,
|
|
24
|
+
value: str,
|
|
25
|
+
timeout: Optional[int] = 10,
|
|
26
|
+
parent: Optional[WebElement] = None
|
|
27
|
+
) -> WebElement:
|
|
28
|
+
""" The diference of this to 'find_element_with_wait is bc this dont will return a 'intercepted click' error """
|
|
29
|
+
|
|
30
|
+
if "css" in by:
|
|
31
|
+
by = By.CSS_SELECTOR
|
|
32
|
+
|
|
33
|
+
if parent is None: parent = self.driver
|
|
34
|
+
attp = 0
|
|
35
|
+
while attp < timeout:
|
|
36
|
+
try:
|
|
37
|
+
return WebDriverWait(parent, 1).until(
|
|
38
|
+
EC.presence_of_element_located((by, value))
|
|
39
|
+
).click()
|
|
40
|
+
except ElementClickInterceptedException as e:
|
|
41
|
+
ultima_exception = e
|
|
42
|
+
time.sleep(1)
|
|
43
|
+
attp += 1
|
|
44
|
+
|
|
45
|
+
except Exception as e:
|
|
46
|
+
ultima_exception = e
|
|
47
|
+
attp += 1
|
|
48
|
+
raise SystemError(ultima_exception)
|
|
49
|
+
|
|
20
50
|
def find_element_with_wait(
|
|
21
51
|
self,
|
|
22
52
|
by: str,
|
|
@@ -126,11 +156,9 @@ class Elements:
|
|
|
126
156
|
try:
|
|
127
157
|
localizacao = pyautogui.locateOnScreen(imagem, confidence=tolerancia)
|
|
128
158
|
break
|
|
129
|
-
except:
|
|
130
|
-
localizacao = None
|
|
131
|
-
continue
|
|
159
|
+
except: continue
|
|
132
160
|
|
|
133
|
-
if localizacao
|
|
161
|
+
if localizacao:
|
|
134
162
|
x = localizacao.left + round(localizacao.width / 2)
|
|
135
163
|
y = localizacao.top + round(localizacao.height / 2)
|
|
136
164
|
|
|
@@ -138,12 +166,9 @@ class Elements:
|
|
|
138
166
|
else:
|
|
139
167
|
if not verify: pyautogui.moveTo(x, y)
|
|
140
168
|
|
|
141
|
-
if click_on_final:
|
|
142
|
-
pyautogui.click()
|
|
169
|
+
if click_on_final: pyautogui.click()
|
|
143
170
|
return localizacao
|
|
144
171
|
|
|
145
|
-
else: raise FileNotFoundError()
|
|
146
|
-
|
|
147
172
|
except Exception as e:
|
|
148
173
|
attempts += 1
|
|
149
174
|
ultima_excecao = e
|
bcpkgfox/get_driver.py
CHANGED
|
@@ -78,6 +78,7 @@ class Instancedriver:
|
|
|
78
78
|
def initialize_options(self):
|
|
79
79
|
|
|
80
80
|
if self.nav.lower() in ["firefox", "fox", "fire", "mozila", "mozila firefox"]:
|
|
81
|
+
self.nav = "firefox"
|
|
81
82
|
self.options = webdriver.FirefoxOptions()
|
|
82
83
|
self.options.add_argument("--disable-blink-features=AutomationControlled")
|
|
83
84
|
self.options.add_argument("--no-sandbox")
|
|
@@ -91,7 +92,8 @@ class Instancedriver:
|
|
|
91
92
|
self.options.add_argument("--disable-blink-features=AutomationControlled")
|
|
92
93
|
self.options.add_argument("start-maximized")
|
|
93
94
|
|
|
94
|
-
elif self.nav.lower()
|
|
95
|
+
elif self.nav.lower() in ["chrome", "google", "chromium", "chrome browser", "browser chrome", "browser_chrome", "browser-chrome"]:
|
|
96
|
+
self.nav = "chrome"
|
|
95
97
|
self.options = webdriver.ChromeOptions()
|
|
96
98
|
self.options.add_argument("--disable-blink-features=AutomationControlled")
|
|
97
99
|
|
|
@@ -187,7 +189,7 @@ class Instancedriver:
|
|
|
187
189
|
import undetected_chromedriver as uc # Recommended over standard driver
|
|
188
190
|
import random
|
|
189
191
|
import time
|
|
190
|
-
from fake_useragent import UserAgent
|
|
192
|
+
# from fake_useragent import UserAgent
|
|
191
193
|
|
|
192
194
|
# Configure options
|
|
193
195
|
options = uc.ChromeOptions()
|
|
@@ -213,9 +215,9 @@ class Instancedriver:
|
|
|
213
215
|
# options.add_argument(f"--proxy-server=http://user:pass@ip:port")
|
|
214
216
|
|
|
215
217
|
# Randomize user agent
|
|
216
|
-
ua = UserAgent(browsers=['chrome'], platforms=['win32', 'linux', 'macos'])
|
|
217
|
-
user_agent = ua.random
|
|
218
|
-
options.add_argument(f"user-agent={user_agent}")
|
|
218
|
+
# ua = UserAgent(browsers=['chrome'], platforms=['win32', 'linux', 'macos'])
|
|
219
|
+
# user_agent = ua.random
|
|
220
|
+
# options.add_argument(f"user-agent={user_agent}")
|
|
219
221
|
|
|
220
222
|
# Experimental options
|
|
221
223
|
# options.add_experimental_option("excludeSwitches", ["enable-automation"])
|
|
@@ -344,19 +346,36 @@ class Instancedriver:
|
|
|
344
346
|
service = IEService(executable_path=self.driver_path)
|
|
345
347
|
self.driver = webdriver.Ie(service=service, options=options)
|
|
346
348
|
|
|
347
|
-
def
|
|
349
|
+
def add_extensions(self, extension_folder: str,
|
|
348
350
|
config: Optional[bool] = False,
|
|
349
|
-
key: Optional[str|int] = None
|
|
351
|
+
key: Optional[str|int] = None,
|
|
350
352
|
):
|
|
351
|
-
"""
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
353
|
+
"""
|
|
354
|
+
**PARAMETROS**:
|
|
355
|
+
- **extension_folder**: folder or CRX of you extension (auto detection)
|
|
356
|
+
- **config**: if was a capmonster you can turn to True to config
|
|
357
|
+
- **key**: Pass a APIKEY if you needed and want to auto config
|
|
358
|
+
"""
|
|
356
359
|
try:
|
|
360
|
+
|
|
361
|
+
crx_xpi = extension_folder.lower().endswith((".crx", ".xpi"))
|
|
357
362
|
extensao_caminho = self.__resource_path(extension_folder)
|
|
358
363
|
if not os.path.exists(extensao_caminho): extensao_caminho = os.path.abspath(extension_folder)
|
|
359
|
-
|
|
364
|
+
|
|
365
|
+
if self.nav == "chrome":
|
|
366
|
+
if crx_xpi:
|
|
367
|
+
self.options.add_extension(extensao_caminho)
|
|
368
|
+
else:
|
|
369
|
+
self.arguments.add_new_argument(f'--load-extension={extensao_caminho}')
|
|
370
|
+
|
|
371
|
+
else:
|
|
372
|
+
if crx_xpi:
|
|
373
|
+
self.options.add_extension(extensao_caminho)
|
|
374
|
+
else:
|
|
375
|
+
from . import mostrar_mensagem
|
|
376
|
+
mostrar_mensagem(f"Use .CRX (ou .XPI) para o navegador {self.nav}.\n")
|
|
377
|
+
raise RuntimeError("Extensão inválida para esse navegador")
|
|
378
|
+
|
|
360
379
|
except Exception as e:
|
|
361
380
|
logging.error("Erro ao verificar pasta da extensão", exc_info=True)
|
|
362
381
|
raise SystemError("Verificar pasta da extensão") from e
|
|
@@ -364,7 +383,7 @@ class Instancedriver:
|
|
|
364
383
|
if key:
|
|
365
384
|
key = str(key) ; cap_monster_names = ["capmonster", "captchamonster", "monster", "cap-monster", "captcha monster", "captcha-monster", "cmonster", "cap monster"]
|
|
366
385
|
for name in cap_monster_names:
|
|
367
|
-
if name in extension_folder.lower(): self._config_capmonster(key)
|
|
386
|
+
if name in extension_folder.lower() and config: self._config_capmonster(key)
|
|
368
387
|
|
|
369
388
|
def _get_chrome_version(self) -> int:
|
|
370
389
|
"""Get major Chrome version"""
|