如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# -*- 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.qb5.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----%s@qq.com----%s\n" % (user,pwd,QQ,QQ))
# f.write("qq----123456")
f.close()
for i in range (x):
h(i,x)
# 延时
time.sleep( 2 )
|
以上这篇python实现批量注册网站用户的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/liuyukuan/article/details/50458994