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-06-24 05:12
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Original] Batch Processing to Implement Web Page Download (260 bytes) View 6,210 Replies 18
Original Poster Posted 2006-11-01 05:22 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
1. Download the obtained web page source code

@echo off
<"%~f0" more +5 >tmp.vbs
cscript //NoLogo /e:vbscript tmp.vbs %1
del tmp.vbs
goto:eof
Set oDOM = WScript.GetObject(WScript.Arguments(0))
do until oDOM.readyState = "complete"
WScript.sleep 200
loop
WScript.echo oDOM.documentElement.outerHTML


2. Download the obtained web page text

@echo off
<"%~f0" more +5 >tmp.vbs
cscript //NoLogo /e:vbscript tmp.vbs %1
del tmp.vbs
goto:eof
Set oDOM = WScript.GetObject(WScript.Arguments(0))
do until oDOM.readyState = "complete"
WScript.sleep 200
loop
WScript.echo oDOM.documentElement.outerText
Recent Ratings for This Post ( 4 in total) Click for details
RaterScoreTime
redtek +2 2006-11-09 21:46
scriptor +2 2006-12-22 16:14
everest79 +8 2007-04-07 01:15
lfun +1 2007-12-14 17:22

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 2 Posted 2006-11-01 05:26 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Tips:
1. The parameters of this batch processing are relatively strict: there must be http:// or ftp:// before the URL, otherwise an error will occur.
For example, I save the second code as: iGet.bat, then I run
iGet.bat ftp://www.dormforce.net can get the content of an FTP, and then combine with for to output the list of FTP

2. This batch processing will directly output the result to the screen. To save it to a file, use > or >> for redirection

3. The advantage of this batch processing is that it does not require any components (xmlhttp) and can automatically handle encoding problems. The disadvantage is: if the original web page has pop-up ads, it will still pop up. If you want to completely download in the background quietly, you can use the classic iGet.vbs http://xxxxxx C:\down.htm
This iGet.vbs cannot directly get the web page text

Set xPost = CreateObject("Microsoft.XMLHTTP")
xPost.Open "GET",LCase(WScript.Arguments(0)),0
xPost.Send()
Set sGet = CreateObject("ADODB.Stream")
sGet.Mode = 3
sGet.Type = 1
sGet.Open()
sGet.Write(xPost.responseBody)
sGet.SaveToFile LCase(WScript.Arguments(1)),2


[ Last edited by electronixtar on 2006-11-1 at 05:42 AM ]

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 3 Posted 2006-11-01 05:28 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Floor 4 Posted 2006-11-01 05:30 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
I do have an idea. Like


@echo off
<"%~f0" more +5 >tmp.vbs
cscript //NoLogo /e:vbscript tmp.vbs %1
del tmp.vbs
goto:eof

In this way, I have to repeat writing it every time. It would be better to establish a standard batch processing header that can be referenced (include) by the China DOS Union, so that everyone's formats can be unified.

If there are experts who can write a batch processing IDE, heh, it can greatly simplify the writing of batch processing.

[ Last edited by electronixtar on 2006-11-1 at 05:32 AM ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
plp626 +2 2008-01-08 23:13

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 5 Posted 2006-11-01 05:36 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
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 electronixtar at 2006-11-1 05:30:
I actually have an idea, like

this, every time I have to repeat writing, it might be better for the union to establish a standard batch processing header that can be included, and then everyone's format ...

I'm thinking:
set/p 1= Batch processing name:
set/p 2= Batch processing intermediate content:
echo .............

Just thinking about it, but it's best to come up with a writing standard, so that it's easier to read, not written like天书one by one. For example, first write at the beginning
:: Idea:
:: Principle:
and so on
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
plp626 +2 2008-01-08 23:13
Floor 6 Posted 2006-11-01 06:42 ·  中国 浙江 宁波 鹏博士宽带
荣誉版主
★★★
Credits 1,338
Posts 356
Joined 2005-07-15 12:09
20-year member
UID 40733
Gender Male
Status Offline
Re electronixtar

You can specify the template file in "New".
For example, save the above content to D:\BAT\template.cmd
Then add the following registry entry.

Windows Registry Editor Version 5.00


"FileName"="D:\\BAT\\template.cmd"
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +2 2006-11-09 21:46
  ☆开始\运行 (WIN+R)☆
%ComSpec% /cset,=何奈无── 。何奈可无是原,事奈无做人奈无&for,/l,%i,in,(22,-1,0)do,@call,set/p= %,:~%i,1%<nul&ping/n 1 127.1>nul

Floor 7 Posted 2006-11-09 11:30 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
There is no translation needed as the text is in Chinese but the request is to translate from Chinese to English. Wait, no, the user provided "无奈何 兄高招啊!学习" which is Chinese. So the translation is "Brother Nai Wu He, great move! Learning"

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 8 Posted 2006-11-09 21:26 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 9 Posted 2006-12-22 16:17 ·  中国 北京 中国科学院研究生院
银牌会员
★★★
Credits 1,187
Posts 555
Joined 2006-12-21 07:35
19-year member
UID 74129
Gender Male
Status Offline
Not bad

But still borrowed methods like vbs, etc. Can it only use DOS commands and not use IE?
Purely in the DOS black interface, that would be even better.

Haha...
Who can write a batch?
Floor 10 Posted 2007-04-07 00:17 ·  中国 浙江 杭州 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
Cheating. Using VBS. o(∩_∩)o... Haha. But also learned.
Floor 11 Posted 2007-04-07 01:23 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
est has been missing for a while oh

The following is what I got from the Internet


if lcase(right(wscript.fullname,11))="wscript.exe" then
shell.run("cmd.exe /k echo off&cls&cscript //nologo "&chr(34)&wscript.scriptfullname&chr(34))
wscript.quit
end if
Floor 12 Posted 2007-04-07 01:39 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
After seeing the thread starter's post, I have a vague idea. Can the hidden execution of batch processing that we have been pursuing all the time also be achieved by using a template VBS?
Floor 13 Posted 2007-04-07 05:21 ·  中国 四川 成都 教育网
中级用户
★★
Credits 346
Posts 103
Joined 2004-04-06 00:00
22-year member
UID 21852
Gender Male
Status Offline
Floor 14 Posted 2007-04-07 07:12 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
To be honest, are you a sock puppet?
Floor 15 Posted 2008-09-26 22:54 ·  中国 浙江 宁波 电信
初级用户
Credits 62
Posts 24
Joined 2008-09-17 19:59
17-year member
UID 125888
Gender Male
Status Offline
The LZ moved the VBS code into the batch file and gave the VBScript script a new coat~~~

Can there be another pair of batch processing pants under this coat?
That is, the batch processing completes part of the work
When encountering weak functions, it then uses VBS to assist, and the two are mixed, such as

@echo off
IF exist tmp.vbs (start notepad&del tmp.vbs&exit) ELSE goto scr
:scr
<"%~f0" more +6 >tmp.vbs
cscript //NoLogo /e:vbscript tmp.vbs %1
goto:eof
Set oDOM = WScript.GetObject(WScript.Arguments(0))
do until oDOM.readyState = "complete"
WScript.sleep 200
loop
WScript.echo oDOM.documentElement.outerText


The actual effective process of the program is that VBS completes part of the task first, and then the batch processing completes the remaining tasks
I'm a novice, but I've collected a large number of various codes. Some VBS code has a good single function and I want to use it with the help, and then use the relatively easy-to-understand batch processing to make some functional evolutions
Is this idea feasible?
Forum Jump: