https://github.com/chen0495/pythonCrawlerForJSU
登陸學(xué)校成績單查詢網(wǎng)站,修改cookie.
按F12后按Ctrl+R刷新一下,獲取cookie的方法見下圖:
修改爬蟲url為自己的成績單網(wǎng)址.
運行src/main.py文件即可在/result下得到csv文件.
# -*- coding: utf-8 -*- # @Time : 5/29/2021 2:13 PM # @Author : Chen0495 # @Email : 1346565673@qq.com|chenweiin612@gmail.com # @File : main.py # @Software: PyCharm import requests as rq from bs4 import BeautifulSoup as BS import numpy as np import pandas as pd rq.adapters.DEFAULT_RETRIES = 5 s = rq.session() s.keep_alive = False # 關(guān)閉多余連接 header = { # 請更改cookie 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4501.0 Safari/537.36 Edg/92.0.891.1', 'cookie' : 'wengine_vpn_ticketwebvpn_jsu_edu_cn=xxxxxxxxxx; show_vpn=1; refresh=1' } # 請更改url r = rq.get('https://webvpn.jsu.edu.cn/https/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/jsxsd/kscj/cjcx_list', headers = header, verify=False) soup = BS(r.text,'html.parser') head = [] for th in soup.find_all("th"): head.append(th.text) while '' in head: head.remove('') head.remove('序號') context = np.array(head) x = [] flag = 0 for td in soup.find_all("td"): if flag!=0 and flag%11!=1: x.append(td.text) if flag%11==0 and flag!=0: context = np.row_stack((context,np.array(x))) x.clear() flag+=1 context = np.delete(context,0,axis=0) data = pd.DataFrame(context,columns=head) print(data) # 生成文件,親更改文件名 data.to_csv('../result/result.csv',encoding='utf-8-sig')
以上就是python 爬取吉首大學(xué)成績單的詳細(xì)內(nèi)容,更多關(guān)于python 爬取成績單的資料請關(guān)注腳本之家其它相關(guān)文章!
標(biāo)簽:寧夏 龍巖 定西 江蘇 酒泉 商丘 金融催收 云南
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《python 爬取吉首大學(xué)網(wǎng)站成績單》,本文關(guān)鍵詞 python,爬取,吉首,大學(xué)網(wǎng)站,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。