Python實現批量註冊網站使用者
阿新 • • 發佈:2018-11-13
Python實現批量註冊網站使用者
# -*- coding:utf-8 -*-
import random,urllib,urllib2
import re,time
x=input("請輸入需要註冊的數量:")
# x=raw_input() #轉換成字串的## 標題
def h(i,y):
user=str(random.randrange(10000000,99999999))
QQ=str(random.randrange(10001,999999999999))
pwd=str(random.randrange(100000,99999999))
url= "http://www.chuck.com/register.php?do=submit"
data={"username":user,
"password":pwd,
"repassword":pwd,
"email":QQ+"@qq.com",
"qq":QQ,
"sex":"0",
"action":"newuser",
"submit":""}
data=urllib.urlencode(data)
req=urllib2.Request(url,data=data)
print data
# html=urllib2.urlopen(req).read ()
# print(html)
html=urllib2.urlopen(req).read().decode('gbk')
# print(type(html))
reg=u'您已成功註冊成為本站使用者'
reg=re.compile(reg)
r=re.findall(reg,html)
if r!=[]:
print("註冊成功,賬號為%s,密碼為%s,目前註冊到第%s,還剩%s個"%(user,pwd,i+1,y-i-1))
f=open("c:\user.txt","a")
f.write("%s----%s----%[email protected] %s\n" %(user,pwd,QQ,QQ))
# f.write("qq----123456")
f.close()
for i in range(x):
h(i,x)
# 延時
time.sleep(2)