-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcrawler-need-to-fix.py
73 lines (49 loc) · 1.82 KB
/
crawler-need-to-fix.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Codeup OJ Status Crawler
# 시작 날짜-종료 날짜 구현은 이후로 미룸
# 우선 제출 번호 기준으로
#
# Copyright 2019 kimgihong38 All rights reserved.
# https://codeup.kr/userinfo.php?user=kimgihong38
#
#
# 콘텐츠를 허가 없이 크롤링하여 사용하는 것은 불법입니다.
#
# 해당 Crawler Source Code를 활용하여 특정 사이트 크롤링을 하기 전에
# 특정 사이트 운영자에게 허락을 구하고 크롤링 진행을 하기 바랍니다.
#
#
import re
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("https://codeup.kr/status.php")
bsObject = BeautifulSoup(html, "html.parser")
for link in bsObject.find_all('a'):
print(link.text.strip(), link.get('href'))
def inputstartday(): # 시작 날짜 입력 함수
startDay = input('크롤링할 제출 기록 시작 날짜(YYYY-MM-DD) : ')
start=bool(re.match('201\d-[01]\d-[0123]\d',startDay))
if not start:
print('입력된 날짜를 다시 확인해주세요.\n')
inputstartday()
else:
return startDay
def inputendday(): # 종료 날짜 입력 함수
endDay = input('크롤링할 제출 기록 종료 날짜(YYYY-MM-DD) : ')
end=bool(re.match('201\d-[01]\d-[0123]\d',endDay))
if not end:
print('입력된 날짜를 다시 확인해주세요.\n')
inputendday()
else:
return endDay
def main():
print('Codeup Status Crawler')
print('================================')
print('')
print('')
print('제출 일자를 기준으로 크롤링합니다.\n')
print('원하시는 날짜를 기입해주세요.\n')
startDay=inputstartday()
endDay=inputendday()
#input 버그를 해결했다고 가정합시다..ㅠㅠㅠ
if __name__ == '__main__':
main()