使用selenium python在网页搜索引擎中搜索数据

时间:2017-06-27 17:58:47

标签: python-3.x firefox selenium-webdriver web-scraping

自动化工作流程打开网页网址url = https://www.infogreffe.com并在搜索框中输入文字,然后点击搜索图标

我的代码:

from selenium import webdriver
driver = webdriver.Firefox()
driver.implicitly_wait(5)
driver.maximize_window()
driver.get("https://www.infogreffe.com")
alert = driver.find_element_by_id("dijit_form_Button_0_label")
alert.click()
driver.implicitly_wait(5)

search_field = driver.find_element_by_id("phrase")
search_field.clear()
search_field.send_keys("IMERYS")
driver.implicitly_wait(5)
driver.find_element_by_class_name('spinnerContainer').send_keys("IMERYS")
driver.find_element_by_class_name('button').click()

网页加载很长时间后我收到此错误消息:

Traceback (most recent call last):
  File "C:/Users/ARC/PycharmProjects/SeleniumChallenge/info.py", line 5, in <module>
    driver.get("https://www.infogreffe.com")
  File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 268, in get
    self.execute(Command.GET, {'url': url})
  File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 256, in execute
    self.error_handler.check_response(response)
  File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: Timeout loading page after 300000ms

先谢谢

0 个答案:

没有答案