Python Selenium转发Twitter
如何使用Selenium和Python转发最近的推文?我知道如何在api中使用它,但当我尝试使用Selenium时,会出现错误此css选择器应该可以工作:Python Selenium转发Twitter,selenium,Selenium,如何使用Selenium和Python转发最近的推文?我知道如何在api中使用它,但当我尝试使用Selenium时,会出现错误此css选择器应该可以工作: import selenium.webdriver driver = selenium.webdriver.Firefox() driver.get("https://twitter.com/login") driver.find_element_by_css_selector(".js-username-field").send_keys
import selenium.webdriver
driver = selenium.webdriver.Firefox()
driver.get("https://twitter.com/login")
driver.find_element_by_css_selector(".js-username-field").send_keys("username")
driver.find_element_by_css_selector(".js-password-field").send_keys("password")
driver.find_element_by_css_selector("#page-container > div > div.signin-wrapper > form > div.clearfix > button").click()
driver.get("https://twitter.com/DisbeArex")
我会这样做: a=驱动程序。按类(“IconContainer”)查找元素 …对于a中的i:
……a.单击(0)
我认为这应该行得通。在第一条推特上转发 ret='section.css-1dbjc4n>div:n子级(2)>div:n子级(1)> 分区:第n个孩子(1)>分区:第n个孩子(1)>分区:第n个孩子(1)> 分区:第n个孩子(1)>文章:第n个孩子(1)>分区:第n个孩子(2)> 分区:第n个孩子(2)>分区:第n个孩子(2)>分区:第n个孩子(2)> 分区:第n个孩子(1)>分区:第n个孩子(1)>分区:第n个孩子(1)> svg:n子级(2)' 找到元素并单击 驱动程序。通过css选择器(ret)查找元素。单击() 确认转发 驱动程序。通过“css”选择器(“div.r-1j3t67a:nth child(1)”查找元素。单击() 附言:我对这些新twitter布局中的疯狂名字一无所知,例如:r-1j3t67a。不管怎么说,我成功地转发了第一条推特。其他人怎么办 葡萄牙语:Olá@Arthur Silva,一个明哈·dúvida的顾问?在execute self.error\u handler.check\u response(response)文件“C:\Python27\lib\site packages\selenium\webdriver\remote\webdriver.py”的第201行,返回self.\u parent.execute(命令,参数)文件“C:\Python27\lib\site packages\selenium\webdriver\remote\errorhandler.py”,第194行,在check_response引发异常_类(message、screen、stacktrace)中,selenium.common.exceptions.WebDriverException:message:元素在点(513.5、9.25)处不可单击。其他元素将收到单击:
driver.find_element_by_css_selector(".js-stream-item .ProfileTweet-action--retweet div").click()