为了账号安全,请及时绑定邮箱和手机立即绑定

使用Selenium和WebDriver(Chrome)Python OSX在Instagram

使用Selenium和WebDriver(Chrome)Python OSX在Instagram

慕田峪7331174 2019-12-07 14:03:24
我想使用硒登录instagram,但似乎无法在字段中输入值。这是我的脚本:#go to this addressbrowser.get('https://www.instagram.com')#sleep for 1 secondssleep(1)#find the 'login' button on homepagelogin_elem = browser.find_element_by_xpath('//*[@id="react-root"]/section/main/article/div[2]/div[2]/p/a')#navigate to login pagelogin_elem.click()从这里开始遇到麻烦:#locate the username field within the formunform = browser.find_element_by_xpath('//*[@id="f3b8e6724a27994"]')#clear the fieldtextunform.clear()#enter 'test' into fieldunform.send_keys('test')
查看完整描述

3 回答

?
慕村225694

TA贡献1880条经验 获得超4个赞

instagram正在应用某种方法来保留动态id,xpath和css,每次在页面上发生重新加载时,属性都会更改其值,从而使单击或设置值更加困难


查看完整回答
反对 回复 2019-12-07
  • 3 回答
  • 0 关注
  • 718 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信