硒instagram机器人,但xpath无法正常工作

时间:2018-07-22 07:15:31

标签: python selenium selenium-webdriver instagram bots

首先,我认为webdriver无法找到xpath,但是即使包含隐式等待也是如此。它仍然引发我错误

def login(self):
    driver = self.driver
    driver.get("https://www.instagram.com/")
    driver.implicitly_wait(10)
    login_button = driver.find_element_by_xpath("//a[@href='/accounts/login/']")
    login_button.click()
    time.sleep(6)
    user_name_elem = driver.find_element_by_xpath("//input[@name='username']")
    user_name_elem.clear()
    user_name_elem.send_keys(self.username)
    passworword_elem = driver.find_element_by_xpath("//input[@name='password']")
    passworword_elem.clear()
    passworword_elem.send_keys(self.password)
    passworword_elem.send_keys(Keys.RETURN)
    time.sleep(6)
  

文件“ crawl_profile.py”,第35行,登录       user_name_elem = driver.find_element_by_xpath(“ // input [@ name ='username']”)文件   “ /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py”,   第293行,在find_element_by_xpath中       return self.find_element(by = By.XPATH,value = xpath)文件“ /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py”,   第752行,在find_element中       'value':value})['value']文件“ /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py”,   第236行,执行       self.error_handler.check_response(响应)文件“ /usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py”,   第192行,在check_response中       引发exception_class(消息,屏幕,堆栈跟踪)selenium.common.exceptions.WebDriverException:消息:未知错误:   缺少或无效的“ entry.level”(会话信息:chrome = 67.0.3396.99)   (驱动程序信息:chromedriver = 2.27.440174   (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),平台= Mac OS X 10.13.6   x86_64)

1 个答案:

答案 0 :(得分:1)

您需要将chromedriver.exe更新到最新版本。

现在您正在使用旧的chromedriver版本 (会话信息:chrome = 67.0.3396.99)  (驱动程序信息:chromedriver = 2.27.440174)

您需要使用: (ChromeDriver 2.39) (支持Chrome v66-68)

请访问此链接:-chroemdriver latest version updates