Skip to content

Commit f1a4695

Browse files
committedOct 7, 2021
미완성 과제
1 parent b1f7335 commit f1a4695

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
 

Diff for: ‎homework3.py

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import os
2+
import requests
3+
from requests.models import HTTPError
4+
5+
def set_url():
6+
print("Welcome to IsItDown.py!")
7+
print("Please write a URLs you wnat to check. (separated by comma)")
8+
x = input('').lower().split(',') #url 통으로 받고 split으로 구분 후 리스트화
9+
10+
#print(x[1].strip())
11+
for i in x:
12+
if('http' in i):
13+
r = requests.get(i)
14+
# if(r.status_code == 200):
15+
# print(i + " is up!")
16+
# # elif(r.status_code == 404):
17+
# # print(i + " is down!")
18+
# else:
19+
# print(i + " is down!")
20+
try:
21+
print(i + " is up!")
22+
except HTTPError as e:
23+
print(i + " is down!")
24+
25+
else: #http 빠진 것 채워넣기
26+
my_string = i
27+
split_str = my_string.split()
28+
split_str.insert(0,'https://')
29+
final_str = ''.join(split_str)
30+
r2 = requests.get(final_str)
31+
32+
# print(r2.raise_for_status())
33+
if(r2.status_code == 200):
34+
print(final_str + " is up!")
35+
elif(r2.raise_for_status() == None):
36+
print(final_str + " is down!")
37+
38+
num = input("Do you want to start over? y/n ")
39+
if(num == 'y'):
40+
set_url()
41+
else:
42+
print("k. bye!")
43+
44+
45+
set_url()
46+
47+

0 commit comments

Comments
 (0)