Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
epub-crawler
比较版本
94ff77bd664572646cff0d50c2fcf05b0fe37bb0...1a9ebdba15be408413ff193135ce022caa6f8fba
E
epub-crawler
项目概览
OpenDocCN
/
epub-crawler
9 个月 前同步成功
通知
1
Star
22
Fork
6
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
epub-crawler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
源分支
1a9ebdba15be408413ff193135ce022caa6f8fba
选择Git版本
...
目标分支
94ff77bd664572646cff0d50c2fcf05b0fe37bb0
选择Git版本
比较
Commits (3)
https://gitcode.net/OpenDocCN/epub-crawler/-/commit/8428f07fda01db0a5dec0b3c5fb22148e1c2d8bb
2023-03-11 11:51:45
2023-03-11T11:51:45+08:00
wizardforcel
562826179@qq.com
https://gitcode.net/OpenDocCN/epub-crawler/-/commit/411da0520f7ea0505fa017702d735c906008f331
2023-03-11 11:52:30
2023-03-11T11:52:30+08:00
wizardforcel
562826179@qq.com
https://gitcode.net/OpenDocCN/epub-crawler/-/commit/1a9ebdba15be408413ff193135ce022caa6f8fba
Merge branch 'master' of github.com:apachecn/epub-crawler
2023-03-11T11:52:48+08:00
wizardforcel
562826179@qq.com
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
3 deletion
+25
-3
EpubCrawler/__main__.py
EpubCrawler/__main__.py
+20
-2
EpubCrawler/util.py
EpubCrawler/util.py
+5
-1
未找到文件。
EpubCrawler/__main__.py
浏览文件 @
1a9ebdba
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
from
urllib.parse
import
urljoin
from
urllib.parse
import
urljoin
import
sys
import
sys
import
json
import
json
import
yaml
import
warnings
import
warnings
from
pyquery
import
PyQuery
as
pq
from
pyquery
import
PyQuery
as
pq
import
time
import
time
...
@@ -182,8 +183,25 @@ def main():
...
@@ -182,8 +183,25 @@ def main():
if
not
path
.
exists
(
cfg_fname
):
if
not
path
.
exists
(
cfg_fname
):
print
(
'please provide config file'
)
print
(
'please provide config file'
)
return
return
user_cfg
=
json
.
loads
(
open
(
cfg_fname
,
encoding
=
'utf-8'
).
read
())
ext
=
extname
(
cfg_fname
).
lower
()
cont
=
open
(
cfg_fname
,
encoding
=
'utf-8'
).
read
()
if
ext
==
'json'
:
user_cfg
=
json
.
loads
(
cont
)
elif
ext
in
[
'yaml'
,
'yml'
]:
user_cfg
=
yaml
.
safe_load
(
cont
)
elif
ext
==
'txt'
:
urls
=
[
l
.
strip
()
for
l
in
cont
.
split
(
'
\n
'
)]
urls
=
[
l
for
l
in
urls
if
l
]
name
=
re
.
sub
(
'\.\w+$'
,
''
,
path
.
basename
(
cfg_fname
))
user_cfg
=
{
'name'
:
name
,
'url'
:
urls
[
0
]
if
urls
else
''
,
'list'
:
urls
,
}
else
:
print
(
'配置文件必须为 JSON、YAML 或 TXT'
)
return
update_config
(
cfg_fname
,
user_cfg
)
update_config
(
cfg_fname
,
user_cfg
)
if
config
[
'selenium'
]:
if
config
[
'selenium'
]:
...
...
EpubCrawler/util.py
浏览文件 @
1a9ebdba
...
@@ -140,4 +140,8 @@ def size_str_to_int(s):
...
@@ -140,4 +140,8 @@ def size_str_to_int(s):
base
=
float
(
m
.
group
(
1
))
base
=
float
(
m
.
group
(
1
))
factor
=
factor_map
[
m
.
group
(
2
)]
factor
=
factor_map
[
m
.
group
(
2
)]
return
int
(
base
*
factor
)
return
int
(
base
*
factor
)
\ No newline at end of file
def
extname
(
fname
):
m
=
re
.
search
(
r
'\.(\w+)$'
,
fname
)
return
m
.
group
(
1
)
if
m
else
''