2016-12-28 69 views
0

https://sso.toutiao.com/login/?next=/&service=https://mp.toutiao.com/sso_confirm/?redirect_url=/填写用户名 - 密码箱

我试图访问的网站上面,并用程序自动硒和python填写用户名。

它似乎是登录框在Riot.js中写入,我只是无法在HTML中找到用户名元素,我如何自动填充用户名使用硒?

我对硒和Riot.js很新。

任何帮助将不胜感激。


from selenium import webdriver 
from selenium.webdriver.common.keys import Keys 
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC 
from selenium.webdriver.common.by import By 
import pyperclip 
import sys 


chrome_options = webdriver.ChromeOptions() 
prefs = {"profile.default_content_setting_values.notifications" : 2} 
chrome_options.add_experimental_option("prefs",prefs) 
browser = webdriver.Chrome(chrome_options=chrome_options) 
browser.get("https://sso.toutiao.com/login/next=/&service=https://mp.toutiao.com/sso_confirm/?redirect_url=/") 

mobile = browser.find_element_by_id("mobile") 
code = browser.find_element_by_id("code") 

mobile.send_keys("xxxxx") 
code.send_keys("xxxx") 

回答

0

的用户名输入似乎有CSS ID account和XPath //*[@id="account"]。这应该足以让硒进入它:

username_input = browser.find_element_by_xpath('//*[@id="account"]') 
username_input.send_keys('username') 
+0

它的工作原理!非常感谢你!!!! – Retric