有些小说在网上找不到完本下载,只有在线观看。
为了方便下载小说,自己做了个简易的提取器。
先看效果:
再看代码,比较简易,别介意:
import fonts.fontAwesome;
import win.ui;
import godking.vlistEx
import inet.http;
import fsys.dlg;
import fsys.file;
import string.html;
import process
/*DSG{{*/
var winform = win.form(text="小说提取 【光庆出品】";right=950;bottom=694)
winform.add(
edit={cls="edit";text="https://www.bqg70.com/book/32679/";left=16;top=119;right=771;bottom=156;dl=1;dr=1;dt=1;edge=1;font=LOGFONT(h=-14);multiline=1;z=1};
plus={cls="plus";text='\uF00B 分析章节';left=783;top=106;right=933;bottom=156;bgcolor=-59053;color=16777215;dr=1;dt=1;font=LOGFONT(h=-16;name='FontAwesome');notify=1;z=3};
plus2={cls="plus";text='\uF0F6 开始提取';left=391;top=625;right=541;bottom=675;bgcolor=-16744448;color=16777215;db=1;dl=0.41;font=LOGFONT(h=-16;name='FontAwesome');notify=1;z=5};
plus3={cls="plus";text="https://www.bige70.com";left=13;top=37;right=271;bottom=81;bgcolor=-7882530;color=16777215;dl=1;dr=0.72;dt=1;font=LOGFONT(h=-16);notify=1;z=6};
plus4={cls="plus";text="https://www.haobiquge.com";left=279;top=37;right=592;bottom=81;bgcolor=-7882530;color=16777215;dl=0.29;dr=0.38;dt=1;font=LOGFONT(h=-16);notify=1;z=7};
plus5={cls="plus";text="作者网站 光庆·程序·在线 chengxu.online";left=602;top=37;right=933;bottom=81;bgcolor=-16741121;color=16777215;dl=0.63;dr=1;dt=1;font=LOGFONT(h=-16);notify=1;z=9};
static={cls="static";text="输入小说目录网址";left=14;top=91;right=160;bottom=114;color=8421504;dt=1;font=LOGFONT(h=-16);transparent=1;z=4};
static2={cls="static";text="支持以下两个网站";left=14;top=10;right=160;bottom=33;color=8421504;dt=1;font=LOGFONT(h=-16);transparent=1;z=8};
vlistEx={cls="vlistEx";text="自定义控件";left=18;top=175;right=933;bottom=605;db=1;dl=1;dr=1;dt=1;z=2}
)
/*}}*/
var url = {
{
url="https://www.haobiquge.com";
//<dd><a href="/chapter/99527/2507063.html">第1章 震惊!女帝是我老婆!</a></dd>
mulu=`\<dd\>\<a href\=\"(.+?)\">(.+?)\<\/a\>\<\/dd\>`;
br="@<br />";
id="txt"
}
{
url="https://www.bqg70.com";
//<dd><a href ="/book/10930/1.html">第1章 震惊!女帝是我老婆!</a></dd>
mulu=`\<dd\>\<a href \=\"(.+?)\">(.+?)\<\/a\>\<\/dd\>`;
br="@<br />";
id="chaptercontent"
}
}
winform.vlistEx.setColumns({"章节","网址","字数","内容"},{250,300,100,-1}/*列宽*/,1)
winform.vlistEx.setRowHeight(28)
var zhan;
winform.plus.oncommand = function(id,event){
winform.vlistEx.clear();
zhan = null;
if ..string.startWith(winform.edit.text,url[1].url,true) zhan = url[1]
elseif ..string.startWith(winform.edit.text,url[2].url,true) zhan = url[2]
else return ..win.msgbox("请输入正确的小说目录网址");
winform.plus.disabled=true
import godking.http
var mulu = godking.http(winform.edit.text)
if !mulu return ..win.msgbox("获取章节列表失败!");
var mulus = ..string.matches(mulu,zhan.mulu)
if !mulus return ..win.msgbox("获取章节列表失败!");
var t={}
for(i=1;#mulus;1){
..table.push(t,{mulus[i][2],zhan.url++mulus[i][1],"",""})
}
winform.vlistEx.setTable(t,false)
winform.plus.disabled=false
}
winform.plus2.oncommand = function(id,event){
if !zhan return ;
var fname = fsys.dlg.save("文本文件|*.txt","请输入要保存的小说文件名",,winform);
if !fname return ;
winform.plus.disabled=true
winform.plus2.disabled=true
var f = fsys.file(fname,"w");
for(i=1;winform.vlistEx.count;1){
winform.vlistEx.setCellText(i,3,"正在获取")
var t = thread.invokeAndWait(
function(u){
import godking.http;
return godking.http(u);
} , winform.vlistEx.getCellText(i,2)
)
if t {
t = ..string.replace(t,zhan.br,'\r\n ')
t = string.html(t).getEle(zhan.id).innerText()
if t{
f.write(winform.vlistEx.getCellText(i,1));
f.write('\r\n')
f.write(t)
f.write('\r\n')
winform.vlistEx.setCellText(i,3,#t)
winform.vlistEx.setCellText(i,4,..string.trimleft(..string.left(t,50,true),' '))
} else {
winform.vlistEx.setCellText(i,3,"获取失败!")
}
} else {
winform.vlistEx.setCellText(i,3,"获取失败!")
}
winform.vlistEx.ensureVisible(i)
..win.delay()
}
f.close()
..win.msgbox("保存完毕!")
winform.plus.disabled=false
winform.plus2.disabled=false
}
winform.plus3.oncommand = function(id,event){
process.execute("https://www.bige7.com")
}
winform.plus4.oncommand = function(id,event){
process.execute("https://www.haobiquge.com")
}
winform.plus5.oncommand = function(id,event){
process.execute("http://chengxu.online")
}
winform.show();
win.loopMessage();