Tag:re

Tag (re)'s result:

python批量注册脚本

上次用php写了php+mysql实现超原始的注册登录 这个python脚本基于上次的注册页面,实现批量注册。 相关知识点:1.抓包拿数据 2.urllib和urllib2简单用法 3.简单的爬虫操作 4.文件写入   抓包得到数据: #coding:utf-8 import random,urllib,urllib2 import re,time nums = raw_input(“input the number for reg:”) def reg(num,nums): username = str(random.randrange(100000,9999999)) password = str(random.randrange(1000000,99999999)) url=”http://192.168.43.106/reg_check.php” headers = { ‘User-Agent’: ‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36’, ‘Origin’: ‘http://192.168.43.106’, ‘Referer’: ‘http://192.168.43.106/regtest.php’, ‘Content-Type’: ‘application/x-www-form-urlencoded’, } data = {“username”:username, “password”:password, “pwd_again”:password, } data = urllib.urlencode(data) req = urllib2.Request(url,headers=headers,data=data) html = urllib2.urlopen(req).read() reg = u’Success reg!’ reg = re.compile(reg) r = re.findall(reg,html) if r!=[]: print “success reg!—>username=%s,password=%s——(%s/%s)” %(username,password,num+1,nums) f = open(r’E:\python_projects\regusers.txt’,’a’) f.write(“%s—%s(%s)\n” %(username,password,str(num+1))) f.close() for num in range(int(nums)): reg(num,nums) time.sleep(1) 去数据库和网站上看看有没注册成功 成功注册! 这个注册脚本比较简单,后期我有空再优化。

Use python to test url(check_url_speed v1.0)

Environment: win7+python2.7 This program can test url,if the url can open,output normal and use ping to test average speed,else output failed.Then if the url can open but can not ping,I give the url a big number(10000) and output ‘Can not ping  but can open ‘.Finally,I count total urls,normal urls and their ping average speed,also output those urls whick can not ping but can open. #coding:gb2312 #description:check urls and test ping average speed #author:LSA #Date:20170218 import urllib2,time import subprocess import re import optparse #from threading import Thread global count0,count1,count2 count0 = 0 count1 = 0 count2 = 0 global urlave urlave = {} global aves aves = [] global speurls speurls = [] notping = ‘Can not ping but can open!’ def ping_ave_speed(tempUrl): global speurls pingtempUrl = tempUrl.split(‘/’)[2] p = subprocess.Popen([“ping.exe”,pingtempUrl], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = True) out = p.stdout.read() reg = re.compile(“平均 = (\d+)ms”, re.IGNORECASE) if not reg.findall(out): speurls.append(tempUrl) return str(10000) else: return str(reg.findall(out)[0]) def test_url(fname): global count0 global count1 global count2 global aves……