检查静态 .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
$ ```