lightnovel-center / linovelib2epub

Crawl light novel from some websites and convert it to epub.
https://pypi.org/project/linovelib2epub/
GNU Affero General Public License v3.0
78 stars 9 forks source link

下載後的EPUB 內容只有標題, 內文全是NONE #22

Closed seinteller7 closed 1 year ago

seinteller7 commented 1 year ago
from linovelib2epub.linovel import Linovelib2Epub

# warning!: must run within __main__ module guard due to process spawn issue.
if __name__ == '__main__':
    linovelib_epub = Linovelib2Epub(book_id=3279,select_volume_mode=True)
    linovelib_epub.run()

用以上CODE下載回來的EPUB 沒有內文.全顯示成"NONE"。幾個月前一直在用,沒有問題。這幾天就用不了, 謝謝

wdpm commented 1 year ago

该问题已经得到确认,但是需要进一步的问题排查。@seinteller7

经过几秒钟的探索,已经锁定问题原因,是因为混淆js的文件路径变更了,相关链接为:https://w.linovelib.com/themes/zhmb/js/hm.js?v0731d16

具体混淆规则是否变更有待研究,等待后续的修复吧。

seinteller7 commented 1 year ago

謝謝!

wdpm commented 1 year ago

@seinteller7 已修复。你可以确认一下。

seinteller commented 1 year ago

已輸入 pip install linovelib2epub --upgrade 更新, 但下載來的EPUB還是NONE, 我的更新正確程序正確?

wdpm commented 1 year ago

已輸入 pip install linovelib2epub --upgrade 更新, 但下載來的EPUB還是NONE, 我的更新正確程序正確?

不科学,把你的本地logging发上来。 暂时别用pypi模式,使用源码克隆模式吧,pypi很久没有发布了。

seinteller commented 1 year ago

不太懂用「源码克隆模式」... 先試試

seinteller commented 1 year ago

不好意思, 請問這錯誤可如何修正?

(venv) C:\Windows\system32>py -m pip install -r requirements.txt ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

(venv) C:\Windows\system32> (venv) C:\Windows\system32>python -m pip install -e . Obtaining file:///C:/Windows/system32 ERROR: file:///C:/Windows/system32 does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.

wdpm commented 1 year ago

不好意思, 請問這錯誤可如何修正?

(venv) C:\Windows\system32>py -m pip install -r requirements.txt ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

(venv) C:\Windows\system32> (venv) C:\Windows\system32>python -m pip install -e . Obtaining file:///C:/Windows/system32 ERROR: file:///C:/Windows/system32 does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.

抱歉,我的文档说明不够清晰,可能误导了你。我重新更新了源码模式的使用说明。 你所有指令都保证在项目根目录下(linovelib2epub)之下操作,理论上就可以正常运行了。

seinteller commented 1 year ago

謝謝, 我想應該成功更新了, 但下載卻出現: " 2023-10-21,11:01:44 INFO LinovelibMobileSpider linovelib_mobile_spider.py:70 Succeed to get the novel of book_id: 3279 2023-10-21,11:01:45 INFO LinovelibMobileSpider linovelib_mobile_spider.py:229 Succeed to get the catalog of book_id: 3279 2023-10-21,11:01:45 INFO LinovelibMobileSpider linovelib_mobile_spider.py:258 volume: 全一册 2023-10-21,11:01:45 INFO LinovelibMobileSpider linovelib_mobile_spider.py:273 chapter : 作品相关 2023-10-21,11:01:46 WARNING LinovelibMobileSpider utils.py :45 Request https://w.linovelib.com/novel/3279/167340.html succeed but data is empty. 2023-10-21,11:05:29 INFO LinovelibMobileSpider linovelib_mobile_spider.py:70 Succeed to get the novel of book_id: 3279 2023-10-21,11:05:30 INFO LinovelibMobileSpider linovelib_mobile_spider.py:229 Succeed to get the catalog of book_id: 3279 2023-10-21,11:05:30 INFO LinovelibMobileSpider linovelib_mobile_spider.py:258 volume: 全一册 2023-10-21,11:05:30 INFO LinovelibMobileSpider linovelib_mobile_spider.py:273 chapter : 作品相关 2023-10-21,11:05:32 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167340.html 2023-10-21,11:05:32 INFO LinovelibMobileSpider linovelib_mobile_spider.py:273 chapter : 第一章 寻死少女 2023-10-21,11:05:39 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167544.html 2023-10-21,11:05:40 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167544_2.html 2023-10-21,11:05:40 WARNING LinovelibMobileSpider utils.py :45 Request https://w.linovelib.com/novel/3279/167544_3.html succeed but data is empty. " 看來是網路看得比較緊?最近

wdpm commented 1 year ago

2023-10-21,11:05:40 WARNING LinovelibMobileSpider utils.py :45 Request https://w.linovelib.com/novel/3279/167544_3.html succeed but data is empty.

该问题不是合理的行为,已被复现,有关具体原因还需要进一步排查。@seinteller

wdpm commented 1 year ago

Fatal error: Uncaught RedisException: Connection refused in /home/wwwroot/m.linovelib.com/global.php:554 Stack trace: #0 /home/wwwroot/m.linovelib.com/global.php(554): Redis->connect('127.0.0.1', 6379) #1 /home/wwwroot/m.linovelib.com/global.php(282): JieqiCacheRedis->__construct(Array) #2 /home/wwwroot/m.linovelib.com/global.php(2758): JieqiCache::getInstance('redis', Array) #3 /home/wwwroot/m.linovelib.com/modules/article/articleinfo.php(5): include_once('/home/wwwroot/m...') #4 {main} thrown in /home/wwwroot/m.linovelib.com/global.php on line 554

它的redis连接池已经满了,估计它要开限流或者加钱升级资源了。这个情况也会偶尔出现。

wdpm commented 1 year ago

@seinteller 等后续修复吧,我已在本地成功解决此问题。

seinteller commented 1 year ago

謝!

wdpm commented 1 year ago
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>错误_哔哩轻小说</title>
<meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width" />
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="black" name="apple-mobile-web-app-status-bar-style" />
<meta content="telephone=no" name="format-detection" />
<link href="https://w.linovelib.com/themes/zhmb/css/login.css?v505a2" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/scripts/darkmode.js"></script>
</head>
<body>
<section class="aui-flexView"><header class="aui-navBar aui-navBar-fixed"><a href="javascript:history.go(-1)" class="aui-navBar-item"><i class="icon icon-return"></i></a>
<div class="aui-center">
<h2 class="aui-center-title">错误原因</h2>
</div>
</header>
<section class="aui-scrollView">
<div class="aui-ver-head">
<div class="center-header"></div>
</div>
<div class="aui-ver-form">
網站正在被攻擊!<br/><br/>error: Connection refused<br><br>
</div>
</section>
</section>
<script>(function(){var js = "window['__CF$cv$params']={r:'81971d4a0e4c0464',t:'MTY5Nzg2NjI5MS41OTkwMDA='};_cpo=document.createElement('script');_cpo.nonce='',_cpo.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js',document.getElementsByTagName('head')[0].appendChild(_cpo);";var _0xh = document.createElement('iframe');_0xh.height = 1;_0xh.width = 1;_0xh.style.position = 'absolute';_0xh.style.top = 0;_0xh.style.left = 0;_0xh.style.border = 'none';_0xh.style.visibility = 'hidden';document.body.appendChild(_0xh);function handler() {var _0xi = _0xh.contentDocument || _0xh.contentWindow.document;if (_0xi) {var _0xj = _0xi.createElement('script');_0xj.innerHTML = js;_0xi.getElementsByTagName('head')[0].appendChild(_0xj);}}if (document.readyState !== 'loading') {handler();} else if (window.addEventListener) {document.addEventListener('DOMContentLoaded', handler);} else {var prev = document.onreadystatechange || function () {};document.onreadystatechange = function (e) {prev(e);if (document.readyState !== 'loading') {document.onreadystatechange = prev;handler();}};}})();</script></body>
</html>
</body>
</html>

網站正在被攻擊!

先别考虑 w.linovelib.com 了,它目前应该被打爆了。@seinteller。而且它有cloudflare的保护,以后爬虫门槛只会越来越高。

wdpm commented 1 year ago

https://w.linovelib.com/ image

要考虑 web 站 www 了。

wdpm commented 1 year ago

@seinteller 已修复哔哩轻小说的请求headers字段问题,以及初步实现真白萌masiro的小说爬取。具体请更新源码并阅读使用文档。

seinteller commented 1 year ago

剛重新安裝, 哔哩轻小说似乎還未可以? 先暫時轉用其他吧?

2023-10-23,16:45:24 WARNING LinovelibMobileSpider utils.py :45 Request https://w.linovelib.com/novel/3279.html succeed but data is empty. 2023-10-23,16:46:11 INFO LinovelibMobileSpider linovelib_mobile_spider.py:70 Succeed to get the novel of book_id: 3279 2023-10-23,16:46:11 INFO LinovelibMobileSpider linovelib_mobile_spider.py:229 Succeed to get the catalog of book_id: 3279 2023-10-23,16:46:11 INFO LinovelibMobileSpider linovelib_mobile_spider.py:258 volume: 全一册 2023-10-23,16:46:11 INFO LinovelibMobileSpider linovelib_mobile_spider.py:273 chapter : 作品相关 2023-10-23,16:46:12 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167340.html 2023-10-23,16:46:12 INFO LinovelibMobileSpider linovelib_mobile_spider.py:273 chapter : 第一章 寻死少女 2023-10-23,16:46:13 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167544.html 2023-10-23,16:46:13 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167544_2.html 2023-10-23,16:46:13 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167544_3.html 2023-10-23,16:46:13 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167544_4.html 2023-10-23,16:46:14 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167544_5.html 2023-10-23,16:46:14 INFO LinovelibMobileSpider linovelib_mobile_spider.py:273 chapter : 第二章 宛如肥皂泡泡 2023-10-23,16:46:15 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167545.html 2023-10-23,16:46:16 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167545_2.html 2023-10-23,16:46:16 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167545_3.html 2023-10-23,16:46:16 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167545_4.html 2023-10-23,16:46:16 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167545_5.html 2023-10-23,16:46:16 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167545_6.html 2023-10-23,16:46:17 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167545_7.html 2023-10-23,16:46:17 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167545_8.html 2023-10-23,16:46:17 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167545_9.html 2023-10-23,16:46:17 INFO LinovelibMobileSpider linovelib_mobile_spider.py:273 chapter : 第三章 无法兑现的诺言 2023-10-23,16:46:19 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167546.html 2023-10-23,16:46:19 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167546_2.html 2023-10-23,16:46:19 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167546_3.html 2023-10-23,16:46:19 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167546_4.html 2023-10-23,16:46:19 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167546_5.html 2023-10-23,16:46:20 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167546_6.html 2023-10-23,16:46:20 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167546_7.html 2023-10-23,16:46:20 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167546_8.html 2023-10-23,16:46:20 INFO LinovelibMobileSpider linovelib_mobile_spider.py:273 chapter : 第四章 愿妳忘了我 2023-10-23,16:46:21 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167547.html 2023-10-23,16:46:21 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167547_2.html 2023-10-23,16:46:22 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167547_3.html 2023-10-23,16:46:22 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167547_4.html 2023-10-23,16:46:22 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167547_5.html 2023-10-23,16:46:22 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167547_6.html 2023-10-23,16:46:22 INFO LinovelibMobileSpider linovelib_mobile_spider.py:273 chapter : 第五章 寻死的少年 2023-10-23,16:46:23 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167548.html 2023-10-23,16:46:24 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167548_2.html 2023-10-23,16:46:24 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167548_3.html 2023-10-23,16:46:24 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167548_4.html 2023-10-23,16:46:24 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167548_5.html 2023-10-23,16:46:24 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167548_6.html 2023-10-23,16:46:24 INFO LinovelibMobileSpider linovelib_mobile_spider.py:273 chapter : 尾声 2023-10-23,16:46:25 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167549.html 2023-10-23,16:46:25 INFO LinovelibMobileSpider linovelib_mobile_spider.py:273 chapter : 后记 2023-10-23,16:46:25 INFO LinovelibMobileSpider linovelib_mobile_spider.py:352 Processing page... https://w.linovelib.com/novel/3279/167550.html 2023-10-23,16:46:25 INFO LinovelibMobileSpider linovelib_mobile_spider.py:39 (Perf metrics) Fetch Book took: 14.192570499995782 seconds 2023-10-23,16:46:25 INFO Linovelib2Epub linovel.py :368 The data of book(id=3279) except image files is ready. 2023-10-23,16:46:25 INFO LinovelibMobileSpider base_spider.py :199 Image download strategy: ASYNCIO 2023-10-23,16:46:25 INFO LinovelibMobileSpider base_spider.py :116 len of image set = 4 2023-10-23,16:46:25 INFO LinovelibMobileSpider base_spider.py :176 save image: https://w.linovelib.com/files/article/image/3/3279/3279s.jpg ok. 2023-10-23,16:46:25 INFO LinovelibMobileSpider base_spider.py :176 save image: https://img3.readpai.com/3/3279/167340/196446.jpg ok. 2023-10-23,16:46:25 INFO LinovelibMobileSpider base_spider.py :176 save image: https://img3.readpai.com/3/3279/167340/196447.jpg ok. 2023-10-23,16:46:25 INFO LinovelibMobileSpider base_spider.py :176 save image: https://img3.readpai.com/3/3279/167340/196667.jpg ok. 2023-10-23,16:46:25 INFO LinovelibMobileSpider base_spider.py :145 SUCCEED_COUNT: 4 2023-10-23,16:46:25 INFO LinovelibMobileSpider base_spider.py :146 [NEXT TURN]Pending task count: 0 2023-10-23,16:46:25 INFO LinovelibMobileSpider base_spider.py :186 (Perf metrics) Download Images took: 0.25894420000258833 seconds 2023-10-23,16:46:25 INFO EpubWriter linovel.py :37 [Config]: has_illustration: True; divide_volume: False 2023-10-23,16:46:26 INFO EpubWriter linovel.py :56 (Perf metrics) Write epub took: 0.11844620000192663 seconds 2023-10-23,16:46:26 INFO Linovelib2Epub linovel.py :375 Write epub finished. Now delete all the artifacts if set. 2023-10-23,16:46:26 INFO Linovelib2Epub linovel.py :378 ================================================================================

wdpm commented 1 year ago

@seinteller linovelib mobile book_id 3279 我本地是可以的。而且从你上面的log来看,似乎没什么问题。

seinteller commented 1 year ago

下載下來的EPUB: https://1drv.ms/u/c/72f35d40f2182dd0/EVDIgcD0NBRMqiYCXeQE-jsB-018RtNczjcbgDdLTP1Y-g?e=aYoaFV 用不同的軟件打開內容還是none none (連結如有需要可下載後刪除

wdpm commented 1 year ago

@seinteller 你用的什么聊天工具软件,远程协助吧。我本地是没法复现你的情况的

我个人推测还是你的网络问题。我目前也没法访问linovelib了,可能它服务器又寄了。你可以在正常浏览器上测试是否可以正常访问,反正目前我这边也是不行的。

=>十分确定是网络问题,有可能是它服务器暂时错误,或者你本地环境网络不好,都是有可能爬取不到的。该问题与程序无关。

seinteller commented 1 year ago

你好, 我想安裝上出了問題, 所以才下載不了。現在可以,下載到了, 謝謝。 但又一個新的問題, 在cmd cd到安裝的文件夾內輸入..venv\Scripts\activate 然後打開 .py 檔, 運作正常

但如果是直接用windows中的Python打開就會顯示 "ModuleNotFoundError: No module named 'linovelib2epub'" 但我在pip list 是可以見到linovelib2epub...

.venv 是必須每次手動打開? Python 新手, 問題很多, 麻煩你了。

wdpm commented 1 year ago

@seinteller

venv是 python 3.5+ 创建虚拟环境的模块。在 windows系统下,

因此,这一切都是为了将项目依赖和本项目安装到一个特定的虚拟环境中。这么做的原因是为了隔离python项目的运行环境,因为python全局依赖只能有一个软件版本,而本地电脑往往有多个python项目。这是基于python项目开发的最佳实践而采用的隔离做法。

问题答疑

但如果是直接用windows中的Python打開就會顯示 "ModuleNotFoundError: No module named 'linovelib2epub'" 但我在pip list 是可以見到linovelib2epub...

你在这里见到的 linovelib2epub 可能是你以前从pypi下载的linovelib2epub,那是很旧的代码了,已经不可用了。

例如:

> pip list
linovelib2epub                 0.1.2

如果你在全局python环境下运行demo.py,就会发现内容是None的情况。

目前你没法在全局方式简便地运行该项目,因为我很久都没有发布 pypi 的最新包了,爬虫变化太快,后续我不打算发布pypi 包,请经常update源码,以源码模式安装。


.venv 是必須每次手動打開?

对的,必须打开。示意图:

(venv) wdpm  linovelib2epub  ➜ (main)  ♥ 12:02  pip list
Package              Version     Editable project location
-------------------- ----------- ----------------------------------------
aiofiles             23.1.0
aiohttp              3.8.4
aiologger            0.7.0
aiosignal            1.3.1
ansicon              1.89.0
......
linovelib2epub       0.1.3       D:\Code\lightnovel-center\linovelib2epub

D:\Code\lightnovel-center\linovelib2epub表示的是一个本地路径,也就是源码模式的安装。


参阅:

seinteller commented 1 year ago

謝謝你的詳盡分享! ^^

wdpm commented 1 year ago

謝謝你的詳盡分享! ^^

不客气,如果有其他疑问,也可以大胆继续提问。如果该issue已被解决的话,请你自行关闭issue。