-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from typing import Union | ||
|
||
from fastapi import FastAPI | ||
|
||
app = FastAPI() | ||
|
||
|
||
@app.get("/") | ||
def read_root(): | ||
return {"Hello": "World"} | ||
|
||
|
||
@app.get("/items/{item_id}") | ||
def read_item(item_id: int, q: Union[str, None] = None): | ||
return {"item_id": item_id, "q": q} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
LOGIN_URL = "https://smartid.ssu.ac.kr/Symtra_sso/smln_pcs.asp" | ||
PORTAL_URL = "https://saint.ssu.ac.kr/irj/portal" | ||
GRADE_URL = 'https://ecc.ssu.ac.kr/sap/bc/webdynpro/sap/ZCMB3W0017' | ||
SAPTOKEN_URL = "https://saint.ssu.ac.kr/webSSO/sso.jsp?sToken=" | ||
|
||
|
||
SESSION_HEADERS = { | ||
'Accept': '*/*', | ||
'Accept-Encoding': "gzip, deflate, br", | ||
"Accept-Language": "ko-KR", | ||
'Connection': 'keep-alive', | ||
'Host': "ecc.ssu.ac.kr", | ||
'Sec-Fetch-Dest': 'documnet', | ||
'Sec-Fetch-Mode': 'navigate', | ||
'Sec-Fetch-Site': 'none', | ||
'X-XHR-Logon': 'accept', | ||
'Upgrade-Insecure-Requests': '1', | ||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" | ||
} | ||
|
||
# NEW_SESSION_HEADERS = { | ||
# 'Accept': '*/*', | ||
# "Accept-Language": "ko-KR", | ||
# # 'Connection': 'keep-alive', | ||
# # 'Host': "ecc.ssu.ac.kr", | ||
# 'Sec-Fetch-Dest': 'empty', | ||
# 'Sec-Fetch-Mode': 'cors', | ||
# 'Sec-Fetch-Site': 'same-origin', | ||
# 'X-XHR-Logon': 'accept', | ||
# "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import re | ||
from bs4 import BeautifulSoup | ||
|
||
def parse_grade(page_source): | ||
soup = BeautifulSoup(page_source, 'html.parser') | ||
grade_table = soup.find('tbody', {'id': re.compile('WD0...-contentTBody')}) | ||
column_names = ['이수학년도','이수학기','과목코드','과목명','과목학점','성적','등급','교수명','비고'] | ||
check_text = lambda tag: tag.select_one('span').text if tag else None | ||
row_datas = [[check_text(td) for td in tr.select('td > span')] for tr in grade_table.select('tr')[1:]] | ||
grade_data = [{col_name:row_data for col_name, row_data in zip(column_names, row)} for row in row_datas] | ||
print(grade_data) | ||
return grade_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import requests | ||
# from selenium import webdriver | ||
# from selenium.webdriver.chrome.service import Service | ||
# ser = Service("C:/Users/rover0811/chromedriver.exe") # 크롬 드라이버 잡아주는 것 | ||
# op = webdriver.ChromeOptions() # initial | ||
# op.add_experimental_option("excludeSwitches", ["enable-logging"]) # option 주기 | ||
# op.add_argument('--window-size=1920,1080') | ||
# s = webdriver.Chrome(service=ser, options=op) # 초기화 | ||
|
||
|
||
#유세인트 초기 로그인 api | ||
login_url = "https://smartid.ssu.ac.kr/Symtra_sso/smln_pcs.asp" | ||
user_agent = "" | ||
|
||
user_data = { | ||
"in_tp_bit": "0", | ||
"rqst_caus_cd": "03", | ||
"userid": "", | ||
"pwd": "" | ||
} | ||
|
||
header = { | ||
"referer": login_url, | ||
"user-agent": user_agent | ||
} | ||
|
||
session = requests.Session() | ||
|
||
with session as s: | ||
s.post(login_url, headers=header, data=user_data) | ||
login_cookies = requests.utils.dict_from_cookiejar(s.cookies) | ||
session_token = login_cookies['sToken'] | ||
|
||
#여기에 전달 받은 토큰을 넘겨주면 세션이 생성됨 | ||
pass_token_url = f"https://saint.ssu.ac.kr/webSSO/sso.jsp?sToken={session_token}" | ||
|
||
s.get(pass_token_url, headers=header) | ||
header["referer"] = pass_token_url | ||
|
||
#세션을 통해 유세인트 접근하면 접속 성공 | ||
res = s.get("https://saint.ssu.ac.kr/irj/portal", headers=header) | ||
print(res.text) |