File tree 2 files changed +34
-54
lines changed
2 files changed +34
-54
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ from selenium import webdriver
2
+
3
+
4
+ def login (email , password ):
5
+ # 1. 驱动
6
+ browser = webdriver .Chrome ()
7
+
8
+ # 2. 操作浏览器行为
9
+ browser .get ("https://passport.csdn.net/login" )
10
+
11
+ # 3. 找到账号登陆接口并点击
12
+ input_button = browser .find_element_by_xpath ('//div[@class="main-select"]/ul/li[2]/a' )
13
+ input_button .click ()
14
+
15
+ # 4. 输入账号密码,并点击登陆
16
+ # 输入账号
17
+ input_element = browser .find_element_by_xpath (
18
+ '//div[@class="col-xs-12 col-sm-12 control-col-pos col-pr-no col-pl-no"]/input' )
19
+ input_element .send_keys (email )
20
+
21
+ # 输入密码
22
+ input_password = browser .find_element_by_xpath (
23
+ '//div[@class="col-xs-12 col-sm-12 control-col-pos col-pr-no col-pl-no"]/input[@id="password-number"]' )
24
+ input_password .send_keys (password )
25
+
26
+ # 点击登陆
27
+ touch_button = browser .find_element_by_xpath ('//button' )
28
+ touch_button .click ()
29
+
30
+
31
+ if __name__ == '__main__' :
32
+ email = input ("请输入你的账号" )
33
+ password = input ("请输入你的密码:" )
34
+ login (email , password )
You can’t perform that action at this time.
0 commit comments