在windows中使用,输入有关信息查询社工库,本来是网页版的,我把Ajax请求提取出来。粗略的封装下,挺好玩。
#coding:utf8importurllib2,urllibfromBeautifulSoupimportBeautifulSoup
queryWord=raw_input(u"输入查询的字符串:\n".encode('gbk'))deff(queryword):
q=lambdax:urllib.quote(x.decode('gbk').encode('utf8'))
url="http://shegongku.org/passwd/index.php/Index/search/key/%s/vcode/"req=urllib2.Request(url%q(queryword))
req.add_header("User-Agent",r"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)Chrome/33.0.1750.146 Safari/537.36")
req.add_header("X-Requested-With",r'xmlHttPRequest')
res=urllib2.urlopen(req)
dom=BeautifulSoup(res.read())
table=dom.find("table")
trs=table.findAll("tr")fortrintrs[2:]:printtr.text
f(queryword)