1 # -*- coding: utf-8 -*-
2 import urllib,urllib2,cookielib
3 jar=cookielib.CookieJar()
4 opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
5 urllib2.install_opener(opener)
6 postdata=urllib.urlencode({
7 'formhash':'60399bbf',
8 'referer':'http://rs.xidian.edu.cn/forum.php',
9 'username':'smallest',
10 'password':'e10adc3949ba59abbe56e057f20f883e',
11 'questionid':0})
12 headers={'User-Agent':'Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130515 Firefox/17.0 Iceweasel/17.0.6'}
13 req=urllib2.Request(
14 url='http://rs.xidian.edu.cn/member.php?mod=logging&action=login&loginsubmit=yes&frommessage&loginhash=Le38A&inajax=1',
15 data=postdata,
16 headers=headers)
17 result=urllib2.urlopen(req).read()
18 content=urllib2.urlopen('http://rs.xidian.edu.cn/forum.php?mod=viewthread&tid=515359').read()
19 print content