This repository has been archived by the owner on Oct 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
2 changed files
with
93 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# parser.py | ||
import requests | ||
import os, json, re | ||
from bs4 import BeautifulSoup | ||
|
||
# Location of parser.py | ||
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
# HTTP GET Request | ||
request = requests.get('https://homepage.sch.ac.kr/sch/05/05010000.jsp') | ||
|
||
# GET HTML Source | ||
html = request.text | ||
|
||
# Use BeautifulSoup, From HTML Source to Python Object | ||
# First Parameter is HTML Source, Second Parameter is the parser to be used | ||
soup = BeautifulSoup(html, 'html.parser') | ||
|
||
# HTML element using CSS Selector | ||
schedules = soup.find_all('a', {'class' : 'schedule'}) | ||
|
||
for schedule in schedules: | ||
# 날짜 가져오기 성공 | ||
print(schedule.text) | ||
# 세부 내용 가져오기 성공 | ||
print(schedule.get('title')) | ||
|
||
|
||
# GET HTTP Header | ||
header = request.headers | ||
|
||
# GET HTTP Status ( 200 : normal ) | ||
status = request.status_code | ||
|
||
# Check HTTP ( TRUE / FALSE ) | ||
is_HTTP_OK = request.ok |
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