Git Product home page Git Product logo

linkcheck's Introduction

linkcheck

Build Status Tag License

linkcheck was created in order to ensure that none of your files have broken links.

I use it personally to check my documentation, notes and recipes every once in a while for valid URLs. I am aware that in case of Sphinx documentation there is already a bundled linkcheck tool. However this does not work on raw:: sections.

Requirements

  • bash
  • curl

Or use Docker:

Docker hub

https://github.com/cytopia/docker-linkcheck

Examples

Scan all files in current directory for httpd 200

# Ensure all URLs found in all files in current directory return 200
linkcheck

Scan Markdown and text files

# Ensure either 200, 301 or 302 are returned
linkcheck -e 'md,txt' -c '200,301,302' path/to/my/docs

Be strict on sphinx files

# Ensure only 200 is returned
linkcheck -e 'rst' -c '200' path/to/my/docs

Ignore specific URLs

# Ignore localhost, 127.0.0.1 and *.loc domains
linkcheck -i '^http(s)?:\/\/(localhost)|(127\.0\.0\.1|.)|(.+\.loc).*$' path/to/my/docs

Ignore invalid SSL certificates

linkcheck -k -c '200' path/to/my/docs

Follow redirects and only evaluate final HTTP code

# Ensure only 200 is returned from the last redirected page
linkcheck -l -c '200' path/to/my/docs

Show files which have invalid links

linkcheck -v path/to/my/docs

Usage

Usage: linkcheck [-e -i -t -r -c -k -l -v] [<path>]
       linkcheck --version
       linkcheck --help


Options:

-e        Limit search to those file extensions.
          Defaults to limiting on non-binary files.
          Accepts comma separated string of extensions:
            -e txt
            -e txt,rst
            -e sh,py.c,h

-i        Ignore all URLs matching the specified regex.
          Defaults to: ^http(s)?:\/\/(127\.0\.0\.1)|(localhost).*$
          Accepts a single regex string:
            -i '^http(?):\/\/my-comapny.com.*$'

-t        Specify curl timeout in seconds, after which probing stops for one url.
          Defaults to 10 seconds.
          Accepts a positive integer:
            -t 5
            -t 10

-r        Specify how many time to retry probing a single URL, before giving up.
          Defaults to 3 times.
          Accepts a positive integer:
            -r 5
            -r 10

-c        Specify HTTP status codes that are valid for success.
          Any code not specified in here will produce an error for the given URL.
          Defaults to '200'.
          Accepts comma separated string of http status codes:
            -c '200'
            -c '200,301'
            -c '200,301,302'

-k        Ignore invalid SSL certificates for HTTPS connections.
          Defaults to error on invalid SSL certificates.
          This is just a single flag with no other arguments.

-l        Specify whether to follow redirect URLs or not.
          This argument does not accept parameters.
          Defaults to not following redirects.

-v        Be verbose and also show affected files.

--version Show version and exit.
--help    Show this help screen.


Optional arguments:

<path>    Specify what directory to scan files for URLs.
          Defaults to current directory.

License

MIT License

Copyright (c) 2018 cytopia

linkcheck's People

Contributors

cytopia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

linkcheck's Issues

can't parse some characters in links

https://nierautomata.wiki.fextralife.com/How+To+Unlock+the+Secret+Trophy+Shop
https://nierautomata.wiki.fextralife.com/Locked+Chests

leads to

[ERR]  https://nierautomata.wiki.fextralife.com/How HTTP/2 404 
[ERR]  https://nierautomata.wiki.fextralife.com/Locked HTTP/2 404 

or
https://www.baka-tsuki.org/project/?title=Ore_no_Im%C5%8Dto_ga_Konna_ni_Kawaii_Wake_ga_Nai
leads to
[ERR] https://www.baka-tsuki.org/project/?title=Ore_no_Im HTTP/2 404

or
https://www.phoronix.com/scan.php?page=news_item&px=U2-NVMe-PCI-E-SSD-Adapter
leads to
[ERR] https://www.phoronix.com/scan.php?page=news_item HTTP/2 403

Per-domain ignore list

It would be helpful to exclude certain domains from being checked, for when you know ahead of time that checking links on certain domains simply won't work. These are often for private websites, or websites that will require authentication.

How to display the file where errors were found ?

Hi,
I ran linkcheck on my markdown folder and it found some errors but is there a way (except searching for the link in all the files) to display the file path where the error was spotted in the linkcheck result directly ?
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.