python实现批量注册网站用户的示例

yipeiwu_com7年前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.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实现批量注册网站用户的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python实现数据清洗(缺失值与异常值处理)

python实现数据清洗(缺失值与异常值处理)

1。 将本地sql文件写入mysql数据库 本文写入的是python数据库的taob表 source [本地文件] 其中总数据为9616行,列分别为title,link,pric...

centos 安装python3.6环境并配置虚拟环境的详细教程

python3.6下载地址: https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz linux 下python 环境配置 统一...

python 日期操作类代码

完整代码 # -*- coding: utf-8 -*- '''获取当前日期前后N天或N月的日期''' from time import strftime, localtime...

Python import自定义模块方法

python包含子目录中的模块方法比较简单,关键是能够在sys.path里面找到通向模块文件的路径。 下面将具体介绍几种常用情况: (1)主程序与模块程序在同一目录下: 如下面程序结构:...

python正向最大匹配分词和逆向最大匹配分词的实例

正向最大匹配 # -*- coding:utf-8 -*- CODEC='utf-8' def u(s, encoding): 'converted other enco...