2017-04-22 49 views
1

我一直在使用Python腳本和Selenium庫登錄Linkedin幾個月。在過去一週內,它不再有效。使用Selenium登錄到網站停止工作

我不知道是怎麼回事。似乎Linkedin沒有重新命名任何字段。

這裏是我的代碼片段:

#define URL and launch firefox 
mainURL='https://www.linkedin.com/' 
browser=webdriver.Firefox() 
browser.get(mainURL) 
time.sleep(5) 

#first log into linkedin.com 
try: 
    emailElem = browser.find_element_by_id('login-email') 
    emailElem.send_keys('username') 
except: 
    print('Was not able to find an element with the login-email id name.') 

try: 
    passwordElem=browser.find_element_by_id('login-password') 
    passwordElem.send_keys('password') 
    passwordElem.submit() 
except: 
    print('Was not able to find an element with the login-password id name.') 

time.sleep(5) 

任何幫助,將不勝感激,因爲我是一個新手的編碼和無法弄清楚發生了什麼變化。

+1

分享異常日誌 – Andersson

+0

你應該添加輸出日誌太 – ProFan

+0

@Andersson這裏是什麼,是說:ERROR:根:消息 ... 提高exception_class(消息,屏幕,堆棧跟蹤) selenium.common.exceptions.WebDriverException :消息:期望[對象未定義]未定義爲字符串 – user3003374

回答

1

像這些問題(突然無法工作的事情)通常是由過時的驅動程序引起的。更新你的Firefox驅動程序將有所幫助

大多數情況下更新Firefox驅動程序還需要更新Selenium。如果你這樣做,應該很有可能解決問題。