我正在尝试遍历42个站点.. 该脚本适用于4-5个站点。有时3个站点..直到15个站点都没有..然后图片中出现错误。
我的代码如下:
导入时间
导入请求
从硒导入网络驱动程序
sites = []
userid = []
password = []
settings = []
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(“-disable-infobars”)
print(len(sites))
print(len(userid))
print(len(password))
print(len(settings))
count = 5
对于x范围(len(sites)):
try:
requests.get(sites[x])
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get(sites[x])
inputElement = driver.find_element_by_id("user_login")
inputElement.send_keys(userid[x])
inputElement = driver.find_element_by_id("user_pass")
inputElement.send_keys(password[x])
inputElement.submit()
link = driver.find_element_by_id('menu-plugins')
link.click()
driver.find_element_by_xpath('//a[@href="'+settings[x]+'"]').click()
driver.find_element_by_id('save_and_import').click()
count=count+2
time.sleep(count)
driver.quit()
except requests.ConnectionError:
print(sites[x]+"DOWN !!")
continue