python 길수대학 홈 페이지 성적표
https://github.com/chen0495/pythonCrawlerForJSU
환경.
python 3.5 즉 이상
학교 성적표 조회 사이트 에 접속 하여 쿠키 를 수정 합 니 다.
F12 를 누 른 후 Ctrl+R 을 누 르 면 새로 고침 하고 쿠키 를 가 져 오 는 방법 은 다음 그림 을 참조 하 십시오.
파충류 url 을 자신의 성적표 사이트 로 수정 합 니 다.
src/main.py 파일 을 실행 하면/result 에서 csv 파일 을 얻 을 수 있 습 니 다.
결과 전시
전체 코드
# -*- coding: utf-8 -*-
# @Time : 5/29/2021 2:13 PM
# @Author : Chen0495
# @Email : [email protected]|[email protected]
# @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 #
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 이 길수대학 성적 표를 얻 는 상세 한 내용 입 니 다.python 이 성적 표를 얻 는 것 에 관 한 자 료 는 우리 의 다른 관련 글 을 주목 하 세 요!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
로마 숫자를 정수로 또는 그 반대로 변환그 중 하나는 로마 숫자를 정수로 변환하는 함수를 만드는 것이었고 두 번째는 그 반대를 수행하는 함수를 만드는 것이었습니다. 문자만 포함합니다'I', 'V', 'X', 'L', 'C', 'D', 'M' ; 문자열이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.