cj=http.cookiejar.CookieJar()
opener=build_opener(HTTPCookieProcessor(cj))
data={'uid' : uid , 'password' : password } #uid is username to the website
data=urllib.parse.urlencode(data)
data=data.encode(encoding='utf-8')
url='http://202.117.120.37/xdjwWebNew/Servlet/UsersControl' # url is a link to a specific page
request=Request(url,data)
response=opener.open(request)
response.geturl()
它输出:
'http://docs.python.org/2/library/urllib2.html?highlight=urllib'
我不知道有什么问题。任何建议都会有所帮助。