import urllib.request
import re
def urlopen(Cookie,url):
head = {}
head['Accept']='text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8'
head['Accept-Language']='zh-CN,zh;q=0.9'
head['Cache-Control']='max-age=0'
head['Connection']=' keep-alive'
# Cookie 这个要改不同
head['Cookie']= Cookie
head['Host']='jxjyxuexi.chinaacc.com'
head['Referer']='http://jxjyxuexi.chinaacc.com/Sys/Login/?Area=5115,/guangxi/guangxiqu/Home%2Easpx&code=0&msg=succ&ssouid=53703784&username=gx150804112806282&domain=%40chinaacc%2Ecom&sid=6qro0195089vvrfrdq80hdkn34'
head['Upgrade-Insecure-Requests']='1'
head['User-Agent']='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36'
req = urllib.request.Request(url,headers = head)
#加入headers
'''
data = {}
data['username']='350124199012161088'
data['password']='huang1028'
print(data)
#加入的表单数据
data = urllib.parse.urlencode(data).encode('utf-8')
#表单数据输换
#encoding='gbk'
'''
html = urllib.request.urlopen(req)
#访问时加入了headers 和表单data
html = html.read()
return html
def deng():
url = input('请输入学习中心链接:')
Cookie = input('请输入 ‘Cookie’ :')
html = urlopen(Cookie,url)
html =html.decode('utf-8')
cont = re.findall(r'退出登录',html)
if len(cont)==1:
print(cont)
print('已经登陆完成')
else:
print('没有登录成功')