http status
2023. 3. 22. 16:48ㆍIT & Programming/python
from requests import get
websites=[
"google.com",
"https://httpstat.us/502",
"https://httpstat.us/404",
"https://httpstat.us/300",
"https://httpstat.us/200",
"https://httpstat.us/101"
]
#https://httpstat.us/xxx is service for generating HTTP codes
results={}
for website in websites:
if not website.startswith("https://"):
website = f"https://{website}"
code = get(website).status_code
if code >= 500:
results[website] = "5xx / server error"
elif code >= 400:
results[website] = "4xx / client error"
elif code >= 300:
results[website] = "3xx / redirection "
elif code >= 200:
results[website] = "2xx / successful"
elif code >= 100:
results[website] = "1xx / informational response"
print(results)
반응형
'IT & Programming > python' 카테고리의 다른 글
python String method 파이썬 문자열 메소드 (0) | 2025.05.10 |
---|---|
Python의 __main__에 대한 설명 (0) | 2025.05.10 |
파이썬 모듈은? 무엇인가? 코딩이쉬워지는 모듈 (0) | 2025.05.10 |
파이썬(Python) 내장함수에대해 알아보자 (0) | 2025.05.10 |
파이선 자료구조 (0) | 2023.03.22 |