Python Webdriver异常,无错误消息

时间:2018-07-09 18:19:20

标签: python selenium exception selenium-webdriver webdriver

我创建了一个结合了beautifulsoup,硒和pyautogui的程序。它基本上会打开一个网站,然后右键单击将一些图像保存到我的PC上。有趣的是,三天前我首次创建该程序时,它运行良好。而今天它不起作用了,反而给了我一个错误

程序

import requests
from bs4 import BeautifulSoup
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains
import time
import pyautogui

#---------------------------BeautifulSoup--------------------------------#

r=requests.get("http://www.nisb.in")
soup=BeautifulSoup(r.text,'html.parser')
img=[]
img=soup.findAll("img",{"class":"img-thumbnail col-md-4"})
for link in img:
image=link.get("src")
imgname=os.path.split(image)[1]
qm=imgname.find("?")
imgname=imgname[:qm]
# r2=requests.get(image)
# with open(imgname,"wb") as f:
#     f.write(r2.read)
# f.close()
print(imgname)

#---------------------------Selenium--------------------------------#

driver=webdriver.Firefox()
driver.get(image)
time.sleep(5)
actionChains = ActionChains(driver)
search=driver.find_element_by_xpath("/html/body/img")
actionChains.context_click(search).perform()

#---------------------------pyautogui--------------------------------#

pyautogui.FAILSAFE = True
pyautogui.typewrite(['down','down','down','enter'])
time.sleep(3)
pyautogui.moveTo(410,60,duration=2)
pyautogui.click(410,60)
location="C:\Users\Varun Bheemaiah\Desktop\NisbProj\Images"
pyautogui.typewrite(location,0.25)
pyautogui.typewrite(['enter'])
time.sleep(3)
pyautogui.moveTo(733,555,duration=2)
pyautogui.click(733,555)
driver.close()
time.sleep(2)

这是我得到的错误

34689397_1768768153199629_5069689030086492160_o.jpg
Traceback (most recent call last):
  File "nisb.py", line 29, in <module>
    driver=webdriver.Firefox()
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 170, in __init__
keep_alive=True)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 156, in __init__
self.start_session(capabilities, browser_profile)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 245, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 314, in execute
self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 208, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message:

感谢您对该主题的任何帮助

0 个答案:

没有答案