使用fiddler和WireShark进行网络抓包

2016-05-25  本文已影响4359人  KevinCool
登录post.png

如图,可以清楚的获取到网站的headers信息,以及登录的时候发送的post请求是什么形式,这个网站的post还是相当简单的只有username和password两项。

因此如下的代码就可以实现登录:

postDict = {
            "username":self.username,
            "password":self.password
        }
postData = urllib.urlencode(postDict).encode()
response = opener.open(self.logUrl,postData)```

下面是添加headers和处理Cookie的代码:

headers = {
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36",
"Referer":"https://mbsdisclosure.fanniemae.com/PoolTalk2/index.html",
"Connection":"keep-alive",
"Accept-Encoding":"gzip, deflate",
"Accept-Language":"zh-CN,zh;q=0.8",
"Accept":"application/json, text/javascript, /",
"X-Requested-With":"XMLHttpRequest"
}
cookie = cookielib.CookieJar()
handler = urllib2.HTTPCookieProcessor(cookie)
opener = urllib2.build_opener(handler)
header = []
for key,value in headers.items():
elem = (key,value)
header.append(elem)
opener.addheaders = header```

上一篇下一篇

猜你喜欢

热点阅读