Answer the question
In order to leave comments, you need to log in
Why does it crash on the 3rd Selenium circle?
The code should register accounts, but on the 3rd circle it crashes for some reason (
How can I fix it?
from selenium import webdriver
import requests
import time
import re
from random import choice
from string import digits, ascii_uppercase
from multiprocessing import Pool
options = webdriver.ChromeOptions()
options.add_argument("--disable-blink-features=AutomationControlled")
options.add_argument("--incognito")
options.add_argument("--disable-blink-features")
options.add_argument("--disable-blink-features=AutomationControlled")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument("--disable-plugins-discovery");
options.add_argument('--profile-directory=Default')
options.add_argument("--mute-audio")
# options.add_extension("MetaMask.crx")
# options.add_extension("Phantom.crx")
# options.add_argument("--window-size=1920,1080")
def rabota(url):
while True:
try:
r = requests.get("https://www.1secmail.com/api/v1/?action=genRandomMailbox&count=1")
mail = r.text
# mail = "[email protected]"
mal = mail.replace('[', '').replace(']', '').replace('"', '')
print(mal)
mails = mal.split("@")
driver = webdriver.Chrome(executable_path=r"chromedriver\chromedriver.exe", options=options)
driver.get("https://ebot.finance/get-airdrop/84yWTPggWg")
time.sleep(3)
name = ''.join(choice(ascii_uppercase) for i in range(12))
driver.find_element_by_xpath("//input[@name='name']").send_keys(name)
number = ''.join(choice(digits) for i in range(12))
driver.find_element_by_xpath("//input[@name='mobile']").send_keys(number)
driver.find_element_by_xpath("//input[@name='email']").send_keys(mal)
password = ''.join(choice(ascii_uppercase) for i in range(12))
driver.find_element_by_xpath("//input[@name='password']").send_keys(password)
driver.find_element_by_xpath("//input[@name='password_confirmation']").send_keys(password)
driver.find_element_by_xpath("//select[@name='country']").send_keys("A")
driver.find_element_by_class_name("btn-block").click()
time.sleep(30)
h = requests.get(f"https://www.1secmail.com/api/v1/?action=getMessages&login={mails[0]}&domain={mails[1]}") # проверка письма
y = h.json()[0]["id"]
o = requests.get(f'https://www.1secmail.com/api/v1/?action=readMessage&login={mails[0]}&domain={mails[1]}&id={y}')
t = o.json()["body"]
myString_list = [r.group("url") for r in (re.search("(?P<url>https?://[^\s]+)", i) for i in t.split(" ")) if
r is not None]
confirm1 = myString_list[2]
confirm = confirm1.replace('"','')
driver.get(confirm)
time.sleep(3)
driver.find_element_by_id("telegramLink").click()
time.sleep(0.2)
driver.switch_to.window(driver.window_handles[0])
driver.find_element_by_id("twitterLink").click()
time.sleep(0.2)
driver.switch_to.window(driver.window_handles[0])
time.sleep(0.5)
driver.find_element_by_xpath("//button[@type='submit']").click()
time.sleep(2)
print("Зареган", mal)
driver.quit()
except Exception as ex:
print(ex)
finally:
driver.close()
driver.quit()
if __name__ == '__main__':
p = Pool(processes=10)
url = "privetsdplghjkodfhjokdfokhjodkfhjopkedfopjkhpdo[fhopjerpohjopdfhopjdfpjohpjklds[gksdg"
urls = url * 1000
p.map(rabota, urls)
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\util\connection.py", line 96, in create_connection
raise err
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\util\connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\connection.py", line 239, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "C:\Users\Rudy\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1276, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\Rudy\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1322, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\Rudy\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1271, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Rudy\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 1031, in _send_output
self.send(msg)
File "C:\Users\Rudy\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 969, in send
self.connect()
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\connection.py", line 205, in connect
conn = self._new_conn()
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x00000221DE7C8310>: Failed to establish a new connection: [WinError 10061] Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Rudy\AppData\Local\Programs\Python\Python310\lib\multiprocessing\pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "C:\Users\Rudy\AppData\Local\Programs\Python\Python310\lib\multiprocessing\pool.py", line 48, in mapstar
return list(map(*args))
File "E:\Programm\PYYHON\Selenium\main.py", line 79, in rabota
driver.close()
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 688, in close
self.execute(Command.CLOSE)
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\request.py", line 74, in request
return self.request_encode_url(
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\request.py", line 96, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\poolmanager.py", line 375, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\connectionpool.py", line 783, in urlopen
return self.urlopen(
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\connectionpool.py", line 783, in urlopen
return self.urlopen(
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\connectionpool.py", line 783, in urlopen
return self.urlopen(
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "E:\Programm\PYYHON\Selenium\venv\lib\site-packages\urllib3\util\retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=51368): Max retries exceeded with url: /session/7bd4ba0faa877b329ee29a5d33ce6e6c/window (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000221DE7C8310>: Failed to establish a new connection: [WinError 10061] Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение'))
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "E:\Programm\PYYHON\Selenium\main.py", line 86, in <module>
p.map(rabota, urls)
File "C:\Users\Rudy\AppData\Local\Programs\Python\Python310\lib\multiprocessing\pool.py", line 364, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "C:\Users\Rudy\AppData\Local\Programs\Python\Python310\lib\multiprocessing\pool.py", line 771, in get
raise self._value
urllib3.exceptions.MaxRetryError: None: Max retries exceeded with url: /session/7bd4ba0faa877b329ee29a5d33ce6e6c/window (Caused by None)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question