python 虎扑注册检查脚本

ulipad,看着蛮舒服的。

python 虎扑注册检查脚本

图里的代码就是今天晚上的成果。

突然就想看看python这个被很多人说是优雅的语言,于是晚上没事就配了配环境,做了个东西

 #encoding: utf-8
import urllib
import urllib2 #name:要注册的名称
#判断name是否可用
def testUsername(name):
url="http://passport.hupu.com/index.php"
params={'m':'user','a':'isUsername','username':name}
data1=urllib.urlencode(params)
req=urllib2.Request(url,data1)
response=urllib2.urlopen(req)
res=response.read()
status=eval(res)['code']
if status=='':
return True
return False #path:文件名
#读取文件中的名字,返回文件中未注册的名称
def showUseableName(path): list_name=[]
file=open(path)
for line in file:
line=line.strip('\n')
line=line.decode('gbk').encode('utf8')
if testUsername(line):
list_name.append(line)
return list_name items=showUseableName('list.txt')
for item in items:
print item.decode('utf8').encode('gbk')
raw_input()

会读取list.txt中的用户名去检测是否注册,如果没有注册就会显示出来。

python优雅不优雅没感觉到,但是写着蛮舒服的

上一篇:Metasploit连接postgres数据库


下一篇:POJ1699Best Sequence(DFS)