【问题标题】:raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=49426):raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=49426):
【发布时间】:2021-07-17 13:44:27
【问题描述】:

我正在编写一个必须在特定时间执行脚本的机器人。第一个脚本运行良好,但第二个不想。抛出此错误 urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=50039): Max retries exceeded with url: /session/ff59b4e8d80282f58c766e631996b3b3/window (由 NewConnectionError(':建立新连接失败:[WinError 10061]。

我的代码

from selenium import webdriver
import time
import schedule

options = webdriver.ChromeOptions()
options.add_argument("--disable-blink-features=AutomationControlled")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument("user-data-dir=./chromeprofile")
options.add_argument('--disable-extensions')
# options.add_argument("--incognito")
options.add_argument("--disable-plugins-discovery")
options.add_argument("--start-maximized")
driver = webdriver.Chrome(r'C:\Users\Ilya\PycharmProjects\University_BOT\Chrome\chromedriver.exe', options=options)
url = 'https://meet.google.com/lookup/gy7njx5dia?authuser=1&hs=179'

''' first_second_lesson_monday
first - Номер тижня
second - пара по счоту

'''

first_monday = {
    'IT' :  'https://meet.google.com/urb-rjsp-wqm',
    'Urkaine_Language': 'https://meet.google.com/lookup/axjfog62dw?authuser=1&hs=179'
}


def second_first_lesson_wednesday():
    try:
        driver.get(url = 'https://meet.google.com/urb-rjsp-wqm' )
        time.sleep(3)
        off_micro = driver.find_element_by_xpath('//div[@class="U26fgb JRY2Pb mUbCce kpROve uJNmj QmxbVb HNeRed"]').click()
        time.sleep(4)
        off_cam = driver.find_elements_by_xpath('//span[@class="DPvwYc JnDFsc dMzo5"]')
        off_cam[1].click()
        time.sleep(4)
        press_coninue = driver.find_element_by_xpath('//span[@class="NPEfkd RveJvd snByac"]').click()
        time.sleep(60)

    except Exception as ex:
        print(ex)
    finally:
        driver.close()
        driver.quit()
schedule.every().day.at("13:28").do(second_first_lesson_wednesday)




def second_second_lesson_wednesday():
    try:
        driver.get(url= 'https://meet.google.com/lookup/hvug6sxjey?authuser=1&hs=179')
        time.sleep(3)
        off_micro = driver.find_element_by_xpath('//div[@class="U26fgb JRY2Pb mUbCce kpROve uJNmj QmxbVb HNeRed"]').click()
        time.sleep(4)
        off_cam = driver.find_elements_by_xpath('//span[@class="DPvwYc JnDFsc dMzo5"]')
        off_cam[1].click()
        time.sleep(4)
        press_coninue = driver.find_element_by_xpath('//span[@class="NPEfkd RveJvd snByac"]').click()
        time.sleep(40)

    except Exception as ex:
        print(ex)
    finally:
        driver.close()
        driver.quit()
schedule.every().day.at("14:35").do(second_second_lesson_wednesday)

def second_third_lesson_wednesday():
    try:
        driver.get(url='https://meet.google.com/lookup/e6kettrs2b?authuser=1&hs=179')
        time.sleep(3)
        off_micro = driver.find_element_by_xpath('//div[@class="U26fgb JRY2Pb mUbCce kpROve uJNmj QmxbVb HNeRed"]').click()
        time.sleep(4)
        off_cam = driver.find_elements_by_xpath('//span[@class="DPvwYc JnDFsc dMzo5"]')
        off_cam[1].click()
        time.sleep(4)
        press_coninue = driver.find_element_by_xpath('//span[@class="NPEfkd RveJvd snByac"]').click()
        time.sleep(30)

    except Exception as ex:
        print(ex)
    finally:
        driver.close()
        driver.quit()


schedule.every().day.at("14:39").do(second_third_lesson_wednesday)


while True:
    schedule.run_pending()
    time.sleep(1)

【问题讨论】:

    标签: python python-3.x selenium


    【解决方案1】:

    首先,您面临的错误意味着脚本无法访问该网址。这可能是由于 SSL 证书、google meet 不支持漫游器或与您的网络相关的其他原因。很可能是因为像 thread 这样的超时,我建议使用 webbot 而不是 selenium,因为它更通用,或者使用其他线程中的建议。

    【讨论】:

      猜你喜欢
      • 2021-02-21
      • 2019-10-30
      • 2019-09-24
      • 2014-01-27
      • 1970-01-01
      • 1970-01-01
      • 2020-07-19
      • 2022-11-07
      • 2018-10-11
      相关资源
      最近更新 更多