import httplib2
class usd():
def __init__(self,user_id,password,k_num,k_id):
self.user_id=user_id
self.password=password
self.k_num=[]
self.k_num=k_num
self.k_id=[]
self.k_id=k_id
def GetCookies(self):
try:
header = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language:zh-CN,zh': 'q=0.8',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'Content-Length': '26',
'Content-Type': 'application/x-www-form-urlencoded',
'Host': 'jwxt.imu.edu.cn',
'Origin': 'http://jwxt.imu.edu.cn',
'Referer': 'http://jwxt.imu.edu.cn/',
'Upgrade-Insecure-Requests': '1',
'User - Agent': ' Mozilla / 5.0(Windows NT 10.0; Win64; x64) AppleWebKit / 537.36(KHTML, likeGecko) Chrome / 55.0.2883.75Safari / 537.36'
}
link = httplib2.Http()
content,response=link.request("http://jwxt.imu.edu.cn/loginAction.do?zjh="+self.user_id+"&mm="+self.password,"GET",header)
data=str(response.decode("gb2321")).replace(" ","")
if "不正确" in data or "你输入的证件号不存在" in data:
return "login fail"
else :
print(content)
return "login succeed"
except Exception as f:
print(f)
return "login fail"
# control this class to achieve selecting courses
def main():
k_num=[]
k_id=[]
user_id="0161123434"
password=""
w=usd(user_id,password,k_num,k_id)
data=w.GetCookies()
print(data)
出现了C:\Users\ASUS\AppData\Local\Programs\Python\Python35\python.exe C:/Users/ASUS/PycharmProjects/untitled1/tests.py
Process finished with exit code 0
问题是怎么回事,新手不懂求解