Когда я пытаюсь выполнить веб-очистку, я получаю следующую ошибку:
[10816
Я попытался игнорировать ошибки сертификата, но получил ту же ошибку. Могу ли я попробовать что-нибудь еще?
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from bs4 import BeautifulSoup
import time
# Set up the webdriver
options = webdriver.ChromeOptions()
options.add_argument('headless')
options.add_argument('--ignore-certificate-errors')
driver = webdriver.Chrome(options=options)
# Navigate to the login page
driver.get('http://notthewebsite.net:8163')
# Wait for the login popup to appear and switch to it
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, 'username')))
popup = driver.window_handles[1]
driver.switch_to.window(popup)
# Enter the login credentials and submit the form
username_input = driver.find_element(By.NAME, 'username')
username_input.send_keys('not the username')
password_input = driver.find_element(By.NAME, 'password')
password_input.send_keys('password')
login_button = driver.find_element(By.NAME, 'login')
login_button.click()
# Switch back to the main window
driver.switch_to.default_content()
# Navigate to the web scraping page
driver.get('http://notthewebsite:8163/admin/queues.jsp')
# Add a delay to allow the page to load
time.sleep(5)
# Get the HTML of the page
html = driver.page_source
# Parse the HTML using BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
# Find the element 0
element = soup.find('td', text='0')
# Open a file to write the output
with open('output.txt', 'w') as file:
# Check if the element exists
if element:
file.write('The element 0 exists\n')
else:
file.write('The element 0 does not exist\n')
# Close the webdriver
driver.quit()
Подробнее здесь: https://stackoverflow.com/questions/793 ... ebscraping