;界面
gui, add, text, x0 y0 w400 h80 vshow
gui, show
;编码
fileencoding,
;fileencoding, UTF-8
savepath = %A_ScriptDir%经典
IfNotExist, % savepath
FileCreateDir, % savepath
Loop
{
;最大页数
if A_Index > 11
Break
;获取列表
URLDownloadToFile, http://www.shuoshuokong.com/jingdian/list_5_%A_Index%.html, %A_Temp%list.html
;处理文字
FileRead, content, %A_Temp%list.html
FileDelete, %A_Temp%list.html
StringReplace, content, content, `r, , All
StringSplit, line, content, `n
Loop % line0
{
tmp_line := line%A_Index%
If RegExMatch(tmp_line,".*
.*title=""(.*)"".*href=""(/jingdian/d*.html).*",m) ;匹配文章页标题/连接
{
title = %m1%
url = http://www.shuoshuokong.com%m2%
filename = %title%
;处理文件名特殊字符
Loop
{
if RegExMatch(filename,"(\|/|*|""|*|?|||)")
filename := RegExReplace(filename,"(\|/|*|""|*|?|||)","")
Else
Break
}
filepath = %savepath%%filename%.txt
GuiControl, , show, %url%`n%filepath%
catchpage(url,filepath)
;传递给处理页面的函数
}
}
}
MsgBox, 64, 提示, 已完成!
ExitApp
catchpage(page,file){
static i
i++
;下载
URLDownloadToFile, % page, %A_Temp%catch_%i%.tmp
FileRead, content, %A_Temp%catch_%i%.tmp
StringReplace, content, content, `r, , All
StringSplit, line, content, `n
main =
;文章从158行开始
Loop % line0 - 157
{
index := A_Index+157
tmp_line := line%index%
;遇到结束标志收尾
if tmp_line =
{
;替换html标签
Loop
{
if RegExMatch(main,"]*>")
main := RegExReplace(main,"]*>","")
Else
Break
}
;保存
FileAppend, %main%, %file%
FileDelete, %A_Temp%catch_%i%.tmp
Return
}
main .= tmp_line "`n"
}
}