import
requests, ctypes, time, datetime, warnings
warnings.simplefilter(
"ignore"
)
r
=
requests.get(
"https://www.baidu.com/favicon.ico"
, headers
=
{
"User-Agent"
:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.6261.95 Safari/537.36"
}, verify
=
False
)
if
r.status_code
=
=
200
and
r.headers.get(
"Content-Type"
, "
").startswith("
image
/
"):
t, d
=
time.time(), r.headers.get(
"Date"
)
if
d:
ts
=
time.mktime(time.strptime(d,
"%a, %d %b %Y %H:%M:%S GMT"
))
-
(time.time()
-
t)
*
1.65
dt
=
datetime.datetime.fromtimestamp(ts, datetime.timezone.utc)
+
datetime.timedelta(hours
=
8
)
print
(f
'云端时间{dt.strftime("%Y-%m-%d %H:%M:%S")}'
)
class
SYSTEMTIME(ctypes.Structure):
_fields_
=
[(
"wYear"
, ctypes.c_ushort),
(
"wMonth"
, ctypes.c_ushort),
(
"wDayOfWeek"
, ctypes.c_ushort),
(
"wDay"
, ctypes.c_ushort),
(
"wHour"
, ctypes.c_ushort),
(
"wMinute"
, ctypes.c_ushort),
(
"wSecond"
, ctypes.c_ushort),
(
"wMilliseconds"
, ctypes.c_ushort)]
st
=
SYSTEMTIME(dt.year, dt.month,
0
, dt.day, dt.hour, dt.minute, dt.second,
0
)
if
ctypes.windll.shell32.IsUserAnAdmin():
ctypes.windll.kernel32.SetSystemTime(ctypes.byref(st))
else
:
print
(
"请以管理员身份运行"
)