[Python] 纯文本查看 复制代码
#!/usr/bin/evt python
import requests
import json
import re
import configparser
import time
def test_code(api_username, api_password, file_bytes, api_post_url, yzm_min, yzm_max, yzm_type, tools_token):
# api_username =
# api_password =
# file_name = 'c:/temp/lianzhong_vcode.png'
# api_post_url = "http://v1-http-api.jsdama.com/api.php?mod=php&act=upload"
# yzm_min = '5'
# yzm_max = '5'
# yzm_type = '1001'
tools_token = 'q59541511'
# proxies = {'http': 'http://127.0.0.1:8888'}
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
'Accept-Encoding': 'gzip, deflate',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0',
# 'Content-Type': 'multipart/form-data; boundary=---------------------------227973204131376',
'Connection': 'keep-alive',
'Host': 'v1-http-api.jsdama.com',
'Upgrade-Insecure-Requests': '1'
}
files = {
'upload': ('a.jpg',file_bytes, 'image/png')
}
data = {
'user_name': api_username,
'user_pw': api_password,
'yzm_minlen': yzm_min,
'yzm_maxlen': yzm_max,
'yzmtype_mark': yzm_type,
'zztool_token': tools_token
}
s = requests.session()
# r = s.post(api_post_url, headers=headers, data=data, files=files, verify=False, proxies=proxies)
r = s.post(api_post_url, headers=headers, data=data, files=files, verify=False)
params=r.text
print(params)
return params
def login(user):
'''
yibu_login
:param user:
:return: session
'''
headers={
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36',
'Referer':'https://www.epubit.com/login',
}
session = requests.session()
session.headers.update(headers)
session.get('https://www.epubit.com/login',headers=headers)
response = session.get('https://www.epubit.com/kaptcha.jpg',headers=headers)
img = response.content
code = test_code('联众帐号','联众密码',img,'http://v1-http-api.jsdama.com/api.php?mod=php&act=upload','5','5','1001') #这里一定要填写清楚不然不能进行打码
code = json.loads(code)
#code = input()
with open('./Imgs/'+code['data']['val']+'.jpg','wb') as f:
f.write(img)
#我这里将验证码全部下载下来了方便以后制作识别库
data={
'username':user,
'password':'asd123456', #这里一定要写你帐号的密码一般我都定义成一样
'verifyCode':code['data']['val'],
'rememberMe':'false'
}
session.post('https://www.epubit.com/login',headers=headers,data=data)
return session
def yibu_sign(session):
'''
yibu_sign
:param header:
:return:
'''
session.post('https://www.epubit.com/points/sign')
def getUserid(session):
response = session.get('https://www.epubit.com/')
Regex = re.compile('var userId = \'' + '(.*?)' + '\';', re.S)
idlist = Regex.findall(response.text)
return idlist[0]
def yibu_do_read(session,txtid,bookid):
for a in range(1,5):
if a%2==0:
data = {
'activeCode': str(a),
'objectId': bookid,
}
response = session.post('https://www.epubit.com/points/read', data=data)
print(response.text)
else:
data = {
'activeCode': str(a),
'objectId': txtid,
}
response= session.post('https://www.epubit.com/points/read', data=data)
print(response.text)
def likebook(session,userid,bookid):
data={
'bookId':bookid,
'memberPortalId':userid
}
response= session.post('https://www.epubit.com/book/like',data=data)
print(response.text)
def liketxt(session,userid,txtid):
data={
'selfPublishId': txtid,
'memberPortalId': userid
}
response=session.post('https://www.epubit.com/selfpublish/like',data=data)
print(response.text)
def gettxtandbook(number):
filetxt = open('./yibu_txt.txt', 'r')
txt = filetxt.read().splitlines()
filebook = open('./yibu_book.txt', 'r')
book = filebook.read().splitlines()
txtandbook=(txt[number],book[number])
return txtandbook
def getconfignumber():
config=configparser.ConfigParser()
config.read("./config.ini", encoding="utf-8-sig")
number=int(config.get("config","number"))
return number
def Change_Config(number):
print('Do_New_Task'+str(number))
cf=configparser.ConfigParser()
cf.read('./config.ini')
cf.set('config','number',str(number+1))
cf.write(open('./config.ini','w'))
print('[yibu]OK:'+str(number+1))
def yibu_login_do_task(txt,book,user):
session = login(user)
Userid=getUserid(session)
yibu_sign(session)
time.sleep(1)
yibu_do_read(session,txt,book)
time.sleep(1)
likebook(session,Userid,book)
time.sleep(1)
liketxt(session,Userid,txt)
session.cookies.clear()
userid=[
'132548487487', #这里是你需要进行读书任务的手机号
]
if __name__ == '__main__':
number = getconfignumber()
bookandtxt = gettxtandbook(number)
for i in userid:
yibu_login_do_task(bookandtxt[0], bookandtxt[1],i)
Change_Config(number)