2017-04-11 31 views
-2

Need xpath of "Liked" button(Image attached here)Python Webdriver無法找到頁面中的喜歡按鈕的Facebook中的xpath

我試過這些,但得到錯誤。

driver.find_element_by_xpath(".//button[contains(text(), 'Liked'").click() 

driver.find_element_by_xpath(".//button[contains(text(), 'Liked'").send_keys(Keys.RETURN) 
+0

共享贊成按鈕的HTML。 FB限制在我的辦公室:( –

+0

Html在這裏分享。@ShoaibAkhtar https://pastebin.com/BbsqZi91 – raaga

+0

爲什麼你需要首先使用硒與Like按鈕進行交互?我不明白那是什麼 – CBroe

回答

0
driver.find_elements_by_xpath(".//button[contains(text(), 'Liked')]").click() 

driver.find_elements_by_xpath(".//button[contains(text(), 'Liked')]").send_keys(Keys.RETURN) 

你錯過了brackets.please以上的XPath嘗試。

您還可以嘗試正式facebbok api數據收集

+0

獲取錯誤** selenium.common.exceptions.InvalidSelectorException:消息:給定xpath表達式「 .// button [contains(text(),'Liked')「)無效:SyntaxError:表達式不是合法表達式** – raaga

+0

請使用編輯過的xpath @raaga – pythonlearner