China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

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!

中国DOS联盟论坛
The time now is 2026-07-15 00:24
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [With Conclusion] Importing Time from a Certain Website Using Bat View 3,176 Replies 17
Original Poster Posted 2006-10-18 05:50 ·  中国 广东 广州 天河区 电信
中级用户
★★
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 ]
Floor 2 Posted 2006-10-18 06:05 ·  中国 甘肃 平凉 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
VBS I don't know. I thought of using wget or VBS to download the web page source code, and then for
Floor 3 Posted 2006-10-18 06:09 ·  中国 广东 广州 天河区 电信
中级用户
★★
Credits 259
Posts 112
Joined 2006-09-18 04:55
19-year member
UID 62928
Gender Male
Status Offline
The question is how to download? As long as the time part can be changed to text, it will be easy to handle.
Floor 4 Posted 2006-10-18 06:16 ·  中国 上海 电信
版主
★★★★★
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?
Floor 5 Posted 2006-10-18 06:29 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 247
Posts 83
Joined 2005-09-12 12:06
20-year member
UID 42446
Gender Male
Status Offline
After I downloaded it with wget, I can extract the time with type + find, and then use echo time | time. I still need to think about the formal bat!
Floor 6 Posted 2006-10-18 06:34 ·  中国 甘肃 平凉 电信
金牌会员
★★★★
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
Floor 7 Posted 2006-10-18 06:49 ·  中国 广东 广州 天河区 电信
中级用户
★★
Credits 259
Posts 112
Joined 2006-09-18 04:55
19-year member
UID 62928
Gender Male
Status Offline
Hehe. Will download... Editing is a bit tedious, but should still be manageable! Hard

First, thank you to the above几位 brothers!

[ Last edited by kennyfan on 2006-10-18 at 06:53 ]
Floor 8 Posted 2006-10-18 09:05 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Actually, the downloaded time is still inaccurate, hehe, it's related to the network speed

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 9 Posted 2006-10-18 09:20 ·  中国 广东 广州 天河区 电信
中级用户
★★
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
Floor 10 Posted 2006-10-18 09:44 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
  Really don't understand why the original poster did this...
  
  Is it just to know the "standard" Beijing time?
Floor 11 Posted 2006-10-18 09:49 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 12 Posted 2006-10-18 10:53 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline

  electronixtar brother found another good command again `top```
Floor 13 Posted 2006-10-18 11:22 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline

ntcmds.chm::/time_w32tm.htm

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 14 Posted 2006-10-18 12:59 ·  中国 广东 广州 天河区 电信
中级用户
★★
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!
Floor 15 Posted 2006-10-18 22:33 ·  中国 四川 成都 教育网
铂金会员
★★★★
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 ]

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Forum Jump: