python爬虫获取强智科技教务系统学科成绩(模拟登录+成绩获取)


python爬取强智科技教务系统,以江苏科技大学为例:本人开发的系统作为参考:https://www.wjn1996.cn/estudy/tools/educationLogin.jsp?school=10289&search=1

以本人账号为例:

 

程序如下,保存为test.py,cmd命令执行python3 test.py+学号+密码。可返回所有成绩列表。

import urllib
import urllib.request
import urllib.parse
import http.cookiejar
PostUrl = "http://jwgl.just.edu.cn:8080/jsxsd/xk/LoginToXk"
cookie =  http.cookiejar.CookieJar()
hander = urllib.request.HTTPCookieProcessor(cookie)
opener = urllib.request.build_opener(hander)
headers ={
    'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    'Connection':'keep-alive',
    'Accept-Language':'zh-CN,zh;q=0.8',
    'Content-Type':'application/x-www-form-urlencoded',
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36'
}
PostData = {
    'USERNAME':'******',#'这里填写学号
    'PASSWORD':'******'#这里填写密码
}
data = urllib.parse.urlencode(PostData).encode(encoding = 'utf-8')
request = urllib.request.Request(PostUrl,data,headers)
response = opener.open(request)
result = response.read().decode('utf-8')
#print(result)
res = opener.open('http://jwgl.just.edu.cn:8080/jsxsd/kscj/cjcx_list')
#print(res.read().decode('utf-8'))
from bs4 import BeautifulSoup
html_text = BeautifulSoup(res.read().decode('utf-8'),'html.parser')
td = html_text.select('td')
all_test_list = []
list = []
for i in td:    
    if i.text != '':
        list.append(i.text)
    else:
        if len(list)>0:
            all_test_list.append(list)
            list = []
        continue
    #print (i.text)
#print(all_test_list)
for i in all_test_list:
    print(i)#这里输出每一个课程的成绩list
 #   print(i[3] , i[4])

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

华师数据学院·王嘉宁

$感谢支持$

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值