简介
对于网页端口的python登录
code
'''
@Description:
@Author: shaonianruntu
@Github: https://github.com/shaonianruntu
@Date: 2020-05-06 17:28:50
LastEditTime: 2021-01-09 21:54:41
'''
import urllib.parse
import urllib.request
url = "http://2.2.2.2"
username = "" # add ihdu student id
pwd = "" # add ihdu passwd
headers = {"Host": "2.2.2.2", "User-Agent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0",\
"Accept-Language": "en-US,en;q=0.5",\
"Accept-Encoding": "gzip, deflate",\
"Content-type":"application/x-www-form-urlencoded; charset=UTF-8",\
"Accept":"*/*",\
"Referer":"http://2.2.2.2/ac_portal/default/pc.html?tabs=pwd",\
"X-Requested-With":"XMLHttpRequest",\
"connection":"keep-alive"}
data = {
"opr": "pwdLogin",
"userName": username,
"pwd": pwd,
"rememberPwd": "1"
}
url = "http://2.2.2.2/ac_portal/login.php"
data = urllib.parse.urlencode(data).encode("utf-8")
req = urllib.request.Request(url, data, headers)
with urllib.request.urlopen(req) as f:
resp = f.read()
print(resp)
---------------------------我的天空里没有太阳,总是黑夜,但并不暗,因为有东西代替了太阳。虽然没有太阳那么明亮,但对我来说已经足够。凭借着这份光,我便能把黑夜当成白天。我从来就没有太阳,所以不怕失去。
--------《白夜行》