import requests
from http.cookiejar import CookieJar
from bs4 import BeautifulSoup
urlBefore = "http://cas.swust.edu.cn/authserver/login"
def getResopnseAfterLogin():
head ={
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36",
}
s = requests.Session()
s.cookies = CookieJar()
r1 = s.get(urlBefore,headers = head)
bsObj1 = BeautifulSoup(r1.text,"html.parser")
#请求登录的页面
lt = bsObj1.find("input",{"name":"lt"})["value"]
execution = bsObj1.find("input",{"name":"execution"})["value"]
#获取网页的流水号
#print(lt)
#print(execution)
params = {
'username':'你的学号',
'password':'你的密码',
'lt':lt,
'dllt':'userNamePasswordLogin',
'execution':execution,
'_eventId':'submit',
'rmShown':'1'
}
#构造提交的数据包
r2 = s.post(urlBefore,data = params,headers = head)
#提交数据包
r3 = s.get(urlB
Python网络爬虫(7)西南科技大学统一认证平台登录
最新推荐文章于 2024-04-02 07:30:00 发布
本文介绍了使用Python进行网络爬虫时,如何针对西南科技大学的统一认证平台进行登录操作,详细讲解了过程中遇到的问题及解决策略。

西南科技大学统一认证平台登录&spm=1001.2101.3001.5002&articleId=54344487&d=1&t=3&u=d401cbe5f22b4d958f4285cc29f0ef9d)
1470

被折叠的 条评论
为什么被折叠?



