python自动签到领京东《豆豆》

2018-06-01 12:48:10 浏览数 (1)

为了省心,自己做了个京东签到的定时器

代码语言:javascript复制
#coding:utf8
from selenium import webdriver
import time
def sign_up():
    url = r'https://passport.jd.com/new/login.aspx?ReturnUrl=http://vip.jd.com/'
    dr = webdriver.Firefox()
    #dr = webdriver.PhantomJS()
    dr.get(url)
    try:
        try:
            login = dr.find_element_by_class_name('login-tab-r')
            login.click()
            loginname = dr.find_element_by_id('loginname')
            loginname.send_keys('xxxxxxxx')#用户名
            password = dr.find_element_by_id('nloginpwd')
            password.send_keys('xxxxxxxxx')#密码
            loginsubmit = dr.find_element_by_id('loginsubmit')
            loginsubmit.click()
            dou = dr.find_element_by_id('checkinBtn')
            dou.click()
        except:
            print "first error"
        try:
            time.sleep(3)
            url_jr = r'https://vip.jr.jd.com'
            dr.get(url_jr)
            jr_dou = dr.find_element_by_id('index-qian-btn')
            jr_dou.click()
        except:
            print "second error"
    except:
        print "error"
    finally:
        dr.close()
sign_up()

0 人点赞