1 Star 0 Fork 0

ocre/ga_register

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
User.py 4.70 KB
一键复制 编辑 原始数据 按行查看 历史
ocre 提交于 2020-06-03 22:46 . first version
import json
import time
from random import choice, randint
from passwd import Passwd
from tools.generate_phone import generate_phone
from tools.idcard import generate_idcard
from tools.pick_imagebase64 import pick_imagebase64
from pick_username import pick_username
class User:
db = []
@classmethod
def load_from_file(cls):
exist_users = []
with open('users.txt', 'r') as f:
lines = f.readlines()
for line in lines:
arr = line.split(',')
user = User()
user.phone = arr[0]
user.nickname = arr[1]
user.passwd = arr[2]
user.invite_code = arr[3]
user.idcard = arr[4]
user.s_province = arr[5]
user.s_city = arr[6]
user.s_county = arr[7]
exist_users.append(user)
return exist_users
def __init__(self):
pass
def gen(self):
self.phone = self.unique_phone()
self.nickname = self.unique_nickname()
self.passwd = self.pick_passwd()
self.invite_code = self.pick_invitecode()
self.idcard = self.unique_idcard()
self.s_province = '重庆市'
self.s_city = '重庆市'
self.s_county = '江北区'
self.country = '86'
self.verify = '12345678'
self.image = self.pick_image()
def makeCopy(self):
copy = User()
copy.phone = self.phone
copy.nickname = self.nickname
copy.passwd = self.passwd
copy.invite_code = self.invite_code
copy.idcard = self.idcard
copy.s_province = self.s_province
copy.s_city = self.s_city
copy.s_county = self.s_county
return copy
def save(self):
new_user = self.makeCopy()
User.db.append(new_user)
self.append_to_file()
def unique_phone(self):
while True:
phone_number = generate_phone()
for user in self.db:
if user.phone == phone_number:
continue
return phone_number
def unique_nickname(self):
while True:
name = pick_username()
for user in self.db:
if user.nickname == name:
continue
return name
def append_to_file(self):
with open('users.txt', 'a') as f:
line = ','.join([self.phone, self.nickname, self.passwd, self.invite_code, self.idcard, self.s_province, self.s_city, self.s_county])
f.write(line + '\n')
def pick_passwd(self):
return Passwd().generate()
def pick_invitecode(self):
codes = ['13439852645']
# codes = ['18510157589']
return choice(codes)
def unique_idcard(self):
while True:
card = generate_idcard()
for user in self.db:
if user.idcard == card:
continue
return card
def pick_image(self):
return pick_imagebase64()
def reg(self):
import requests
reg_url = 'https://ga.kaixinshangcheng.com/wap/login/reg.html'
do_url = 'https://ga.kaixinshangcheng.com/wap/login/reg.html'
# data = {
# 'country': '86',
# 'mobile': '17124931401',
# 'verify': '12345678',
# 's_province': '重庆市',
# 's_city': '重庆市',
# 's_county': '江北区',
# 'nickname': '孤星',
# 'idcard': '350205199505099426',
# 'image': self.pick_image(),
# 'password': '3XUbQofWMUhzt',
# 'invite_code': '13439852645',
# }
# self.phone = '18510157589'
# self.nickname = '舒展'
# self.passwd = 'fype7818'
# self.idcard = '612323198502162126'
data = {
'country': '86',
'mobile': self.phone,
'verify': '12345678',
's_province': '重庆市',
's_city': '重庆市',
's_county': '江北区',
'nickname': self.nickname,
'idcard': self.idcard,
'image': self.pick_image(),
'password': self.passwd,
'invite_code': self.invite_code,
}
line = ','.join([self.phone,self.nickname,self.passwd,self.invite_code,self.idcard,self.s_province,self.s_city,self.s_county])
print(line + '\n')
# return True
session = requests.Session()
session.get(reg_url)
response = requests.post(do_url, data,)
print(response)
print(response.text)
return True
if __name__ == '__main__':
User.db = User.load_from_file()
user = User()
user.gen()
ret = user.reg()
if ret:
user.save()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ocre/ga_register.git
git@gitee.com:ocre/ga_register.git
ocre
ga_register
ga_register
master

搜索帮助