soup = BeautifulSoup(page, 'lxml')
boxes = soup.find_all('div', class_='table-responsive clearfix')
for gb in boxes:
green_boxes = gb.find_all('tr', class_='green')
for l in green_boxes:
links = host + l.find('td', class_='font-weight-bold text-primary p').find('a').get('href')
driver.get(links) #Переходит к первой ссылке
ну и далее по коду ... с ошибками.
Не нужно было бы авторизирроваться и кнопку просмотра номера жать постоянно, проблем бы не было.
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import pyautogui
import undetected_chromedriver.v2 as uc
from bs4 import BeautifulSoup
url = 'https://5140.org/fops/page-1'
host = 'https://5140.org'
options = uc.ChromeOptions()
options.add_argument("--start-maximized")
driver = uc.Chrome(version_main=104, options=options)
wait = WebDriverWait(driver, 10)
driver.get(url)
time.sleep(5)
page = driver.page_source
# with open('page.html', 'w') as file:
# file.write(page)
# file.close()
soup = BeautifulSoup(page, 'lxml')
boxes = soup.find_all('div', class_='table-responsive clearfix')
for gb in boxes:
green_boxes = gb.find_all('tr', class_='green')
for l in green_boxes:
links = host + l.find('td', class_='font-weight-bold text-primary p').find('a').get('href')
driver.get(links) #Переходит к первой ссылке
pyautogui.click(1255, 158)#Нажимает на кнопку авторизации
time.sleep(3)
login = driver.find_element(By.ID, 'loginform-email')
password = driver.find_element(By.ID, 'loginform-password')
time.sleep(3)
login.send_keys('mail@mail.ru')
time.sleep(2)
password.send_keys('password')
time.sleep(3)
input_btn = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button.btn'))).click()#Кликает на кнопку "Войти"
# x, y = pyautogui.position()
# print(x, y)
time.sleep(10)
element_phn = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'a.offset-top-4'))).click() #тут должен нажать на кнопку "Показать номер", но не нажимает
time.sleep(5)
phone = driver.find_element(By.CSS_SELECTOR, 'a.offset-top-4')# а тут должен показать сам номер. (Селекторы одинаковые в обоих случаях)
time.sleep(5)
driver.quit()
driver.close()
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=50445): Max retries exceeded with url: /session/1eec2729881f232e568ee7fdbd4c1755/window (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused'))
driver = uc.Chrome(version_main=104)
driver.get(url)
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=55577): Max retries exceeded with url: /session/c96568a226b4e90d559ec874f088ce6f/window (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused'))