Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
Credits 259 Posts 112 Joined 2006-09-18 04:55 19-year member UID 62928 Gender Male
Status Offline
Is there a way to write a BAT to import the time and date from the website http://www.time.ac.cn/stime.asp into the computer?
Brothers, give me some pointers! I'm getting dizzy thinking about it!
[ Last edited by kennyfan on 2006-10-18 at 13:06 ]
Credits 11,386 Posts 4,938 Joined 2006-07-23 17:10 19-year member UID 59080
Status Offline
Why not align the time of this website with the time of your computer, and then directly use %date%\%time% in the batch processing to call it? Wouldn't this be more convenient?
Credits 4,103 Posts 1,744 Joined 2006-01-20 13:00 20-year member UID 49241 Gender Male From 甘肃.临泽
Status Offline
Originally posted by kennyfan at 2006-10-10 06:09:
The question is how to download? As long as the time part can be changed into text, it will be easy to handle.
wget "http://www.time.ac.cn/stime.asp" Just find stime.asp in the directory where wget is located
Credits 259 Posts 112 Joined 2006-09-18 04:55 19-year member UID 62928 Gender Male
Status Offline
555555 Don't dampen my spirits upstairs..! Got the code done hehe!
@echo off
wget "http://www.time.ac.cn/stime.asp"
for /f "tokens=4 delims=; " %%i in ('find /i "var hrs" stime.asp') do set hrs=%%i
for /f "tokens=4 delims=; " %%i in ('find /i "var min" stime.asp') do set min=%%i
for /f "tokens=4 delims=; " %%i in ('find /i "var sec" stime.asp') do set sec=%%i
time %hrs%:%min%:%sec%
pause
Credits 259 Posts 112 Joined 2006-09-18 04:55 19-year member UID 62928 Gender Male
Status Offline
There's no way. The computer has no power. Although the command w32tm.exe /resync can achieve time synchronization, it requires starting the WINDOWS TIME service. This consumes relatively more memory and is relatively slow!
Credits 7,493 Posts 2,672 Joined 2005-09-02 00:00 20-year member UID 42173 Gender Male
Status Offline
@echo off
<"%~f0" more +5 >tmp.vbs
cscript //NoLogo /e:vbscript tmp.vbs
del tmp.vbs
goto:eof
On Error Resume Next
Set oDOM = WScript.GetObject("http://www.time.ac.cn/stime.asp")
WScript.Sleep 5000
wscript.Echo oDOM.getElementById("clock").innerText
wsript.sleep 5000 is to wait for 5 seconds (5000 milliseconds) to let the web page fully load. You can adjust it appropriately according to your internet speed
[ Last edited by electronixtar on 2006-10-18 at 22:37 ]