这关相当于暴力破解密码,而且密码还很简单,只需要抓取相关信息验证是否正确。
废话不多说,上代码。
#! /user/bin/env python # -*- coding:utf-8 -*- import requests from lxml import etree def findText(url,data): req=requests.post(url,data=data).text content=str(etree.HTML(req).xpath("//h3/text()")) return content def main(): url="http://www.heibanke.com/lesson/crawler_ex01/" for i in range(30): data={"username":"adc","password":i} content=findText(url,data) a="您输入的密码错误, 请重新输入" if a not in content: print(content) print(i) exit(0) if __name__ == '__main__': main()
Comments NOTHING