import urllib
import urllib.request
import http.cookiejar
cookie = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cookie))
#需要POST的数据#
postdata=urllib.parse.urlencode({
'uid':'1111111',
'password':'11111',
'range':2,
'operation':'connect',
'timeout':'1'
})
#自定义一个请求#
req = urllib.request.Request(
url = 'http://ipgw.neu.edu.cn/ipgw/ipgw.ipgw',
data = postdata.encode(encoding='UTF8')
)
#访问该链接#
result = opener.open(req)
#打印返回的内容#
print (result.read())