broken links
v0.3.0-rc1
该工具刮擦指定URL中的所有页面,并检查目标链接是否存在。它报告了原始页面,锚的文本,目标网址以及链接是否正常工作。如果任何链接不起作用,该工具将使用错误代码退出。它还提供了分析的摘要。
它可以作为GitHub操作,命令行工具和Docker容器运行。
该工具也可以用作GITHUB操作,以自动检查存储库中的链接。
url (可选):开始从中刮除的基本URL。默认值为http://localhost:4444/ 。only-errors (可选):如果设置为true,则只显示错误。默认值为false 。ignore-file (可选):忽略文件的路径。默认值为./check-ignore 。如果设置了参数并且不存在文件,则操作将带有错误。有关更多信息,请参见上面的忽略文件格式部分。忽略文件应每行包含一个URL模式。模式可以包括通配符(*)以匹配多个URL。这里有一些例子:
http://example.com/ignore-this-page忽略此特定URL。http://example.com/ignore/* - 忽略以http://example.com/ignore/开头的所有URL。*/ignore-this-path/* - 忽略所有包含/ignore-this-path/ URL。https://*.domain.com* - 忽略domain.com的所有子域,例如https://sub.domain.com或https://sub2.domain.com/page ,等等。此操作不会产生任何输出。但是,在分析结束时,它以:
name : Broken-links Checker
on : [push]
jobs :
check-links :
runs-on : ubuntu-latest
steps :
- name : Checkout repository
uses : actions/checkout@v2
- name : Run Link Checker
uses : merlos/[email protected]
with :
url : ' http://example.com '
only-errors : ' true ' name : MkDocs Preview and Link Check
on :
push :
branches :
- main
jobs :
preview_and_check :
runs-on : ubuntu-latest
steps :
- name : Checkout repository
uses : actions/checkout@v2
- name : Set up Python
uses : actions/setup-python@v2
with :
python-version : ' 3.x '
- name : Install dependencies
run : |
python -m pip install --upgrade pip
pip install mkdocs mkdocs-material
- name : Run MkDocs server
run : mkdocs serve -a 0.0.0.0:4444 &
continue-on-error : true
- name : Wait for server to start
run : sleep 10
- name : Run Link Checker
uses : merlos/[email protected]
with :
url : ' http://localhost:4444 '
only-errors : ' true '
ignore-file : ' ./check-ignore ' name : Quarto Preview and Link Check
on :
push :
branches :
- main
jobs :
preview_and_check :
runs-on : ubuntu-latest
steps :
- name : Checkout repository
uses : actions/checkout@v2
- name : Set up Quarto
uses : quarto-dev/quarto-actions/setup@v2
- name : Render Quarto project
run : quarto preview --port 444 &
continue-on-error : true
- name : Wait for server to start
run : sleep 10
- name : Run Link Checker
uses : merlos/[email protected]
with :
url : ' http://localhost:444 '
only-errors : ' true '
ignore-file : ' ./check-ignore ' 安装软件包:
pip install broken-links使用broken-links命令:
broken-links http://example.com --only-error --ignore-file ./check-ignore命令行参数:
url (可选):开始从中刮除的基本URL。默认值为http://localhost:4444/ 。--only-error或-o (可选):如果设置,则仅显示错误。默认值为false 。--ignore-file或-i (可选):忽略文件的路径。默认值为./check-ignore 。如果未设置参数并且不存在文件,它将检查所有链接。如果设置了参数并且不存在文件,则该工具将带有错误。上面的[忽略文件格式(#ighore-file-format)部分以忽略文件的格式说明。
Docker图像是为这些体系结构构建的: arm64 , amd64和arm7 ,并已在Docker-Hub和Github容器中发行了
docker pull merlos/broken-links:latest
# or from GitHub Container Registry
docker pull ghcr.io/merlos/broken-links:latestdocker run -ti merlos/broken-links https://www.example.com该论点与上面解释的命令行( url , --only-error , --ignore-file )相同。 docker Run使用的-ti选项显示命令的输出。
为了使用--ignore-file参数,您需要安装卷。例如:
docker run -ti -v /path/on/host/to/ignore-file:/ignore-file merlos/broken-links https://www.example.com --ignore-file /ignore-file它是使用Python开发的。因此,您需要在系统中安装Python。
克隆存储库:
git clone https://github.com/merlos/broken-links
cd broken-links设置虚拟环境:
python -m venv venv
source venv/bin/activate在编辑模式( -e )中安装软件包
pip install -e .开始编码!
docker build -t broken-links . docker run --rm broken-links http://example.com --only-error 要运行测试,请使用以下命令:
python -m unittest discover tests分叉并发送拉动请求。请更新/添加单元测试。
该项目已根据Merlos的GNU通用公共许可证v3.0的条款许可。