Skip to main content

检查静态 .html 文件是否存在错误链接

项目描述

存在

递归扫描目录中的静态 html 文件以查找错误或空链接。看看 我为什么写这个,我讨厌错过细节

示例错误或空链接

<a href=""></a>            Empty
<a href></a>               Empty
<a href="python.org"></a>  Any bad link will fail, this one is missing http://

命令行

$ existence /path/to/working/links
Checking links...
57 of 57
All of your links exist!

$ existence /path/to/bad/links
Checking links...
23 of 23
Broken links:
    /path/to/bad/links/index.html@121 'None'
    /path/to/bad/links/other.html@22 'non-existant.html'

Python

>>> from existence import scan
>>> scan("/path/to/working/links")
[]
>>> scan("/path/to/bad/links")
[
    ('None', '/path/to/bad/links/index.html', 121),
    ('non-existant.html', '/path/to/bad/links/other.html', 22)
]
# Returns a list of bad url tuples: [(url, file_name, line_number)]

进度条

启用进度条pip install progressbar==2.3

运行测试

> python -m unittest discover

部署新版本

$ python setup.py sdist
$ ```

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

存在-0.3.0.tar.gz (3.5 kB 查看哈希

已上传 source