header 정보에서 날짜 추출하기
import urllib.request
url = 'web domain'
date = urllib.request.urlopen(url).headers['Date']
print(date)
Sun, 14 May 2023 04:32:47 GMT
한국시간 GMT +0900으로 변경
from datetime import datetime
from datetime import timedelta
date = date.rstrip(' GMT')[5:]
date = datetime.strptime(date, '%d %b %Y %H:%M:%S') + timedelta(hours=9)
print(date)
2023-05-14 13:31:17
'Python > Python Programming' 카테고리의 다른 글
[ Python ] Prometheus metric 값 가져오기 (0) | 2023.05.24 |
---|---|
[ Python ] Linux 파일 (스토리지) 연도별 개수와 총 용량 구하기 (0) | 2023.05.24 |
[ Python ] socket 모듈을 이용한 Port open / close check (0) | 2023.05.23 |
[ Python ] pandas DataFrame을 HTML 형식으로 export 하기. (모니터링 활용) (0) | 2023.05.17 |
[ Python ] ntplib 모듈을 이용한 시간 동기화 점검 (0) | 2023.05.14 |
[ Python ] numpy를 이용한 1차원 배열 2 차원 배열로 변환 (0) | 2023.05.12 |
[ Python ] 날짜형식의 문자열 타입을 datetime 타입 형식으로 변환 (0) | 2023.05.03 |
[ Python ] xml 타입의 데이터 json 으로 변경 (0) | 2023.04.24 |