大佬教程收集整理的这篇文章主要介绍了如何在锁定屏幕的同时使用 Selenium 从带有证书的 Web 下载,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用 SELEnium 从需要证书的网页下载文件。我的计算机上有多个证书,因此每次出现弹出窗口时,我都需要选择正确的证书才能访问该网页的内容。现在,当计算机未锁定时,我可以运行 SELEnium 并自动执行所有这些任务,而不会出现问题。但是在运行我的代码脚本后,如果我锁定屏幕,则会遇到以下错误:
Exception in thread Thread-1:
TraceBACk (most recent call last):
file "C:\Users\lmsun\anaconda3\lib\threading.py",line 926,in _bootstrap_inner
self.run()
file "C:\Users\lmsun\anaconda3\lib\threading.py",line 870,in run
self._target(*self._args,**self._kwargs)
file "C:/Users/lmsun/Desktop/Five Dimensions Energy/liming/ERCOT_Download/ERCOT_Download.py",line 52,in threaded_function2
pyautogui.press('down')
file "C:\Users\lmsun\anaconda3\lib\site-packages\pyautogui\__init__.py",line 1174,in press
failSafecheck()
file "C:\Users\lmsun\anaconda3\lib\site-packages\pyautogui\__init__.py",line 1257,in failSafecheck
raise FailSafeException('pyautogui fail-safe triggered from mouse moving to a corner of the screen. To disable this fail-safe,set pyautogui.FAILSAFE to false. disABliNG FAIL-SAFE IS NOT RECOMMENDED.')
pyautogui.FailSafeException: pyautogui fail-safe triggered from mouse moving to a corner of the screen. To disable this fail-safe,set pyautogui.FAILSAFE to false. disABliNG FAIL-SAFE IS NOT RECOMMENDED.
我可以通过冻结鼠标来消除这个错误。但是在我锁定屏幕后,硒似乎无法再处理证书弹出窗口。有谁知道是否有解决方案?谢谢。
```
def threaded_function(url,browser):
# Calls the website
browser.get(url)
return
def threaded_function2():
global cert_num
# give enough time so that the pop will appear before the press
time.sleep(10) # this needs to be hardcoded,if pass in as a parameter,thread error occurs
# choose the right certification
for i in range(cert_num):
pyautogui.press('down')
time.sleep(2)
pyautogui.press('enter')
return
while ind2 < 5:
try:
if ind2 != 0:
print(f"retrying open {folder_name_2},{ind2 + 1}")
browser = webdriver.Chrome(driver_directory)
# check version of msedgedriver.exe and Edge
str1 = browser.capabilitIEs['browserVersion']
str2 = browser.capabilitIEs['Chrome']['ChromedriverVersion'].split(' ')[0]
if str1[0:2] != str2[0:2]:
print("please download correct msedgedriver version")
return
print("SELEnium operaTing starts...")
cert_num = int(input_df[cert_end + '\''].values.toList()[0]) - 1
cert_dir = input_df[cert_end + '\''].values.toList()[1]
thread2 = threading.Thread(target=threaded_function2)
thread2.start()
thread = threading.Thread(target=threaded_function(url,browser))
thread.start()
thread.join()
thread2.join()
if ind2 != 0:
print(f'The issue is solved,reopen window for {folder_name_2} successfully.')
ind2 = 5
```
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的如何在锁定屏幕的同时使用 Selenium 从带有证书的 Web 下载全部内容,希望文章能够帮你解决如何在锁定屏幕的同时使用 Selenium 从带有证书的 Web 下载所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。