首页 > 学院 > 开发设计 > 正文

python模拟ajax查询社工库...

2019-11-14 17:49:31
字体:
来源:转载
供稿:网友

在windows中使用,输入有关信息查询社工库,本来是网页版的,我把Ajax请求提取出来。粗略的封装下,挺好玩。

#coding:utf8import urllib2,urllibfrom BeautifulSoup import BeautifulSoupqueryWord=raw_input(u"输入查询的字符串:/n".encode('gbk'))def f(queryword):    q=lambda x: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")    for tr in  trs[2:]:        print tr.textf(queryword)

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表