谢谢各位的热心指点!不好意思!章节太多没有仔细看,我怕万一出现这种状况不好处理。如何用老式IE浏览器下载各章节小说?还请高手赐教,再次谢谢🙏
回复 11楼 王咸美
什么破网,目录有两套,对应的章节内容也有差别,说不定也是从哪复制来的。
程序代码:
SET DEFAULT TO (ADDBS(JUSTPATH(SYS(16))))
DECLARE long PostMessageA IN user32 long,long,long,long
IF !FILE("吃喝玩乐之重生1997.dbf")
CREATE TABLE 吃喝玩乐之重生1997 (title C(100), addr C(254), txt M)
USE
ENDIF
USE 吃喝玩乐之重生1997 ALIAS tu
of = CREATEOBJECT("form1")
of.show(1)
CLOSE TABLES ALL
CLEAR ALL
RETURN
DEFINE CLASS form1 as Form
width = 800
height = 600
AutoCenter = .T.
AllowOutput = .f.
ADD OBJECT but as commandbutton WITH left=10,top=10,width=100,height=22,caption="开始"
ADD OBJECT grd as grid WITH left=10,top=40,width=250,height=550,RecordSource="tu",AllowCellSelection=.f.
ADD OBJECT edt as editbox WITH left=280,top=40,width=510,height=550
ADD OBJECT web as Olecontrol with OleClass="Shell.Explorer.2",left=-100
PROCEDURE Destroy
UNBINDEVENTS(this.hWnd)
ENDPROC
PROCEDURE Init
this.web.Silent = .t.
BINDEVENT(this.hWnd, 0x401, this, "myMessage")
ENDPROC
PROCEDURE but.click
ZAP IN "tu"
thisform.edt.value = ""
thisform.web.navigate("http://www./105790648")
ENDPROC
PROCEDURE grd.click
thisform.edt.value = tu.txt
thisform.edt.SelStart = 0
ENDPROC
PROCEDURE web.documentComplete(pdisp, url)
IF (SYS(3095, pdisp) == SYS(3095, this))
PostMessageA(thisform.hWnd, 0x401, 0, 0)
ENDIF
ENDPROC
FUNCTION myMessage(hWnd, uMsg, wParam, lParam)
dom = this.web.document
IF VARTYPE(dom) != "O"
this.Enabled = .t.
RETURN
ENDIF
IF EMPTY(tu.addr)
#if 1 && 0 or 1
* ie版本高试用
lis = dom.getElementsByClassName("line3")
FOR EACH li IN lis
INSERT INTO tu VALUES (li.firstChild.innertext, li.firstChild.href, "")
ENDFOR
#else
* ie版本低试用
lis = dom.getElementsByTagName("li")
FOR EACH li IN lis
IF li.classname == "line3"
INSERT INTO tu VALUES (;
li.getElementsByTagName("a").item[0].innertext,;
li.getElementsByTagName("a").item[0].href, "";
)
ENDIF
ENDFOR
#endif
GO TOP IN "tu"
this.grd.setfocus
this.web.navigate(ALLTRIM(tu.addr))
RETURN
ENDIF
REPLACE tu.txt WITH ALLTRIM(tu.title)+ 0h0D0A0D0A + dom.getElementById("ad").innertext
? ALLTRIM(tu.title)
SKIP IN "tu"
IF !EOF("tu")
this.grd.setfocus
this.web.navigate(ALLTRIM(tu.addr))
RETURN
ENDIF
GO TOP IN "tu"
this.grd.setfocus
this.Enabled = .t.
ENDFUNC
ENDDEFINE
[此贴子已经被作者于2025-11-21 23:45编辑过]
程序代码:Set xhr = CreateObject("MSXML2.XMLHTTP.3.0")
xhr.open "GET", "http://www./105790648", false
xhr.send
If xhr.Status = 200 Then
' 检测编码并处理UTF-8
Dim bytes, htmlContent
bytes = xhr.responseBody
' 检查是否有BOM标记
If LenB(bytes) >= 3 Then
' 检查UTF-8 BOM: EF BB BF
If AscB(MidB(bytes, 1, 1)) = &HEF And _
AscB(MidB(bytes, 2, 1)) = &HBB And _
AscB(MidB(bytes, 3, 1)) = &HBF Then
' 有UTF-8 BOM,去除BOM
bytes = MidB(bytes, 4)
End If
End If
' 将字节数据转换为UTF-8字符串
Set stream = CreateObject("ADODB.Stream")
stream.Type = 1 ' 二进制类型
stream.Open
stream.Write bytes
stream.Position = 0
stream.Type = 2 ' 文本类型
stream.Charset = "UTF-8"
htmlContent = stream.ReadText
stream.Close
Else
WScript.Echo "Error: " & xhr.Status
End If
WScript.Echo "文件内容长度: " & Len(htmlContent)
Set regEx = New RegExp
regEx.Global = True
regEx.IgnoreCase = True
regEx.Pattern = "<a\s+[^>]*href=""([^""]*)""[^>]*title=""([^""]*)""[^>]*>"
Set matches = regEx.Execute(htmlContent)
If matches.Count > 0 Then
For i = 0 To matches.Count - 1
href = matches(i).SubMatches(0)
title = matches(i).SubMatches(1)
WScript.Echo "链接 " & i + 1 & ":"
WScript.Echo "href: " & href
WScript.Echo "title: " & title
WScript.Echo "---"
Next
Else
WScript.Echo "未找到任何链接"
End If请将vbs脚本保存为ansi或者unicode的vbs文件, 不要保存为utf8, 然后以管理员权限在cmd中使用cscript yourvbsfilename.vbs 执行