凤凰山笔记

与2345签到共同成长

刚写下这个标题就有点觉得不科学,其实应该是和2345签到共同变老吧。

整整一年多时间没有发代码,去年也是太累,今年没有好转的迹象,应该会更累的,然后就是慢慢变老……

2345签到一直在改,估计是发现有人自动签到,所以加了很多限制,从他们的js发现很多判定模拟登录的脚本了。但是…其实水平还是有限,无法做到淘宝那么牛逼啊,仔细分析下抓包还有脚本还是能发现些蛛丝马迹,完成程序自动签到的。BTW,他们的js代码好多注释,省去很多弯路哈

本来是用java的httpclient做的,并且想放到sae上面,但是发现本地运行好好的,放sae就有问题,尝试建立cookie的存储还是不行,云空间什么的有点无力。然后试了试sae的python,发现竟然python可以完美的模拟登录,但是python水平实在太弱,就有了下面的代码:

#新版2345自动签到
@app.route('/2345checkin1' , method='GET')
def checkin():
    username = "xxxx@126.com"
    password = "自己把密码md5一下"
    cmd = "login"
    weakpass = "0"
    vTime = "抓包获取"
    weakpass = "0"
    showWay = "ajax"
    forward = "http://jifen.2345.com/m/login.php"

    # Init
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
    urllib2.install_opener(opener)

    # Login登录
    login_url = 'http://jifen.2345.com/jifenLogin.php'
    login_data = urllib.urlencode({ 'cmd':cmd,'forward':forward,'password':password,'username':username,'vTime':vTime,'weakpass':weakpass,'showWay':showWay})
    login_headers = {'Referer':'http://jifen.2345.com/', 'User-Agent':'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36 2345chrome v2.3.0.2200'}
    login_request = urllib2.Request(login_url, login_data, login_headers)
    login_response = urllib2.urlopen(login_request).read()

    #get md5code
    index_url = "http://jifen.2345.com/index.php"
    index_request = urllib2.Request(index_url,None , login_headers)
    index_response = urllib2.urlopen(index_request).read()

    #pattern这段主要是官方为了防止模拟领取写的脚本验证了
    u_pattern = re.compile(r'var u = "(.*)";')
    u_result = u_pattern.search(index_response)
    u = u_result.group(1)

    code_pattern = re.compile(r'var code = "(.*)";')
    code_result = code_pattern.search(index_response)
    code = code_result.group(1)

    token = md5(u+code)

    #checkin签到
    chekin_url = "http://jifen.2345.com/jifen/every_day_signature_new.php"
    checkin_data = urllib.urlencode({ 'sign_token':token})
    checkin_headers = {'Referer':'http://jifen.2345.com/', 'User-Agent':'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36 2345chrome v2.3.0.2200','X-Requested-With':'XMLHttpRequest'}
    checkin_request = urllib2.Request(chekin_url, checkin_data, checkin_headers)
    checkin_response = urllib2.urlopen(checkin_request).read()

    #buy
    buy_url = "http://buy.2345.com/sign_up/"
    buy_headers = {'Referer':'http://buy.2345.com/?sign=1', 'User-Agent':'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36 2345chrome v2.3.0.2200','X-Requested-With':'XMLHttpRequest'}
    buy_request = urllib2.Request(buy_url, None, buy_headers)
    buy_response = urllib2.urlopen(buy_request).read()

    return buy_response

完成的事情:
1、自动登录
2、自动签到
3、自动领取buy.2345.com的签到金币,据说可以提现的

cloudroc wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
很惭愧,只做了些微小的工作,您的支持将鼓励我继续努力创作!