랭귀지/python
python 서버 시간 확인
유키공
2018. 12. 5. 17:39
python 서버 시간 확인하기
response 메시지 헤더에 있는 서버 시간정보 값을 가져옵니다.strptime() : 문자열을 날짜/시간으로 변환
mktime() : 일시를 초 단위 시간으로 변환
#-*- coding: utf-8 -*- import urllib.request import urllib.error import time date = urllib.request.urlopen('http://www.google.com').headers['Date'] print(date) time = int(time.mktime(time.strptime(date, '%a, %d %b %Y %H:%M:%S %Z'))) print(time)Tue, 04 Dec 2018 07:38:24 GMT
1543876704