本帖最后由 /bq 于 2025-12-3 08:24 编辑
使用说明:
1、打开程序
2、在微信中浏览文章
3、在需要导出的页面tab上右键“复制链接” ,程序会自动下载文章。
4、程序中预览界面可以直接复制出文章,也可以在程序目录下 "公众号名称\发布日期“目录下入查看html文件。
5、选择"pdf","docx"输出格式,需要再次点击下载,然后在相应目录下生成指定格式文件。
修正
1、修正标题中包含“|”时无法保存问题
2、修正日志乱码问题
3、修正标题中包含“/”时无法保存错误
下载地址: https://pan.baidu.com/s/1kJbX2u8QbDUOTi0t3aN6VQ?pwd=wx1s
实现原理:
就是一个页面下载工具,然后对网页源码进行截取、替换的过程,你可以用F12打开源码,然后搜索jsdecode,然后前面有nick_name的是标题,create_date就是发布日期,content这个是网页真实源码,把真实源码里面的%3C这些替换一下就成,要替换的字符列表就是jsdecode里面的东西,最后加上html的头,就是正常文章页面。下面的源码就是截取,替换过程使用delphi的实现。
源码里面的img有一个属性data-src,这个就是图片的位置,替换为src就可以直接显示图片了,其它就是保存文件等操作,另存为pdf就是把html修改后缀为doc,然后ole调用word打开doc,另存为格式“17”,这个就是pdf文件。
核心源码:
[Delphi] 纯文本查看 复制代码 with idhtp do
begin
aTitle := Get(edtUrl.text);
aContent := aTitle;
aNick := aTitle;
aDate := aTitle;
System.delete(aTitle, 1, pos('title: JsDecode(', aTitle) + 16);
System.delete(aTitle, pos('''),', aTitle), Length(aTitle));
aTitle := aTitle.Replace('|', '_');
System.delete(aDate, 1, pos('create_time: JsDecode(', aDate) + 22);
System.delete(aDate, pos(' ', aDate), Length(aDate));
System.delete(aNick, 1, pos('nick_name: JsDecode(', aNick) + 20);
System.delete(aNick, pos('''),', aNick), Length(aNick));
Self.Caption := aNick + ' ' + aTitle;
System.delete(aContent, 1, pos('content_noencode: JsDecode(', aContent) + 27);
System.delete(aContent, pos('''),', aContent), Length(aContent));
aContent := aContent.replace('\x5c', '\').replace('\x0d', '\r').replace('\x22','"').replace('\x26', '&').replace('\x27', '\').replace('\x3c', '<').replace('\x3e', '>').replace('\x0a', '\n').replace('data-src', 'src').replace('max-width: 100%;width: 100%;box-sizing: border-box;height: auto !important;','width:500px');
mmoContent.Text :='<html><body><section style="box-sizing: border-box;text-align: center;font-size: x-large;">' +aTitle + '</section>' + aContent + '</body></html>';
aPath := format('%s\%s\%s\%s.%s', [ExtractFilePath(ParamStr(0)), aNick,aDate, aTitle, 'html']);
ForceDirectories(ExtractFilePath(aPath));
mmoContent.Lines.SaveToFile(aPath);
mmoLog.Lines.Add('文章下载完成:' + aTitle + ' ' + edtUrl.Text);
end;
|