Beispiel #1
0
 def denglu(self, uname, pword):
     #try:
     # 定位到iframe
     iframe = browser.find_element_by_id("alibaba-login-box")
     # 切换到iframe
     browser.switch_to.frame(iframe)
     # 输入账号密码,点击登录按钮
     browser.find_element_by_id("fm-login-id").send_keys(uname)
     browser.find_element_by_id("fm-login-password").send_keys(pword)
     browser.find_element_by_id("fm-login-submit").click()
     time.sleep(3)
     # 滑动验证码
     action = ActionChains(browser)
     source = browser.find_element_by_xpath(
         "//*[@id='nc_1_n1t']/span")  # 需要滑动的元素
     action.click_and_hold(source).perform()  # 鼠标左键按下不放
     # 这里每次移动的位置都一样的话,会被反爬虫机制限制滑不到最后
     action.move_by_offset(33, 0).perform()  # 需要滑动的坐标
     time.sleep(0.1)
     action.move_by_offset(43, 0).perform()
     time.sleep(0.3)
     action.move_by_offset(53, 0).perform()
     time.sleep(0.1)
     action.move_by_offset(103, 0).perform()
     time.sleep(0.2)
     #action.release().perform()  # 释放鼠标
     self.getloginbutton().click()  #滑到最后还要再点一次登录
     time.sleep(5)
Beispiel #2
0
 def getusername(self):
     username = browser.find_element_by_id("fm-login-id")
     return username
Beispiel #3
0
 def getloginbutton(self):
     loginbutton = browser.find_element_by_id("fm-login-submit")
     return loginbutton
Beispiel #4
0
 def getslide(self):
     slide = browser.find_element_by_id("nc_1_n1z")
     return slide
Beispiel #5
0
 def getpassword(self):
     password = browser.find_element_by_id("fm-login-password")
     return password