[神器]微林每日礼包自动签到脚本 | 阿Q博客

分享互联网干货
首页 » VPS教程 » [神器]微林每日礼包自动签到脚本

[神器]微林每日礼包自动签到脚本

VPS教程 2016-03-14 1459 0
- N +

vlink

 

微林干啥用的?这个不多说了,老司机懂的,不懂你问我。

此神器需要配合Crontab使用,啥?又不懂Crontab?点击这里查看Crontab使用教程。

此神器需要安装PIL库,如果是Ubuntu用户,直接

sudo apt-get build-dep python-imaging python-pip -y && pip install Pillow 

即可,其它操作系统/发行版自行搜索“发行版+PIL库”,肯定会有相应的教程。

脚本执行后如果打印为 None 则表示签到成功,签到失败会打印相应错误信息

直接上代码


#!/usr/bin/python2
# -*- coding: utf-8 -*-

#
# This's an auto-sign script for vnet.link
# You should install PIL first, for Ubuntu 14.04:
# sudo apt-get build-dep python-imaging python-pip -y && pip install Pillow
#

from PIL import Image, ImageEnhance
import urllib, urllib2, cookielib, io, json, time

NUM_TABLE = [[[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0, 0, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0, 1, 1], [1, 0, 0, 1, 1, 1, 1, 0, 0, 1], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 1, 1, 1, 1, 0, 0, 1], [1, 1, 0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 0, 1, 1, 1]], [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1, 1, 1, 1, 0], [1, 0, 0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], [[1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, 0], [0, 1, 1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 1, 1, 0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 0, 0, 0, 1, 1]]]

def gen_table(threshold):
table = []
for i in range(256):
if i < threshold: table.append(0) else: table.append(1) return table def image_to_number(img): number = 0 max_count = 0 for i in range(10): count = 0 for x in range(9): for y in range(10): if img.getpixel((x, y)) == NUM_TABLE[i][x][y]: count += 1 if count > max_count:
max_count = count
number = i
return number

def image_to_string(img):
enhancer = img.convert('L')
enhancer = ImageEnhance.Brightness(enhancer)
enhancer = enhancer.enhance(4)
enhancer = enhancer.point(gen_table(150),'1')
enhancer = enhancer.crop((9, 3, 63, 13))
string = ''
for i in range(6):
img = enhancer.crop((9*i, 0, 9*(i+1), 10))
string += str(image_to_number(img))
return string

def login_and_sign(username, password):
cookie = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))

data = {'username': username, 'password': password}
opener.open('https://vnet.link/login_do', urllib.urlencode(data))

res = opener.open('https://vnet.link/openapi/v1/regcode?action=checkcode')
image = Image.open(io.BytesIO(res.read()))
code = image_to_string(image)
res = opener.open('https://vnet.link/openapi/v1/regcode?action=gift1&num=' + code)
tt = time.strftime('%Y-%m-%d %X',time.localtime(time.time()))
print('[%s] %s' % (tt, json.loads(res.read())['data'].encode('UTF-8')))

login_and_sign('username', 'password')

关键字:, ,
分享到您的社交平台:

发表评论: