Skip to main content

Check you site for broken links!

Project description

PyAnchor

PyPI version GitHub Black CodeCov Build

Dead links are an annoyance for websites with an extensive amount of content. A side from the negative impact on SEO, dead links are an annoyance for any user that clicks on one.

PyAnchor is primarily for checking the HTTP response on all links on a page. You can integrate it into your development workflow so that users never see a 404 in the first place.

Install

PyAnchor requires Python 3.6 and above.

MacOS / Linux:

$ python3 -m pip install pyanchor

Windows:

> python -m pip install pyanchor

Using the CLI

The CLI can be invoked with the pyanchor command. A URL must be provided.

Basic example for a single page:

> pyanchor https://mysite.com/

Note: all provided URLs must include a valid HTTP scheme.

If you want to check all links on a website, and not just a single page, a sitemap.xml URL may be provided and flagged with --sitemap.

Example:

> pyanchor https://mysite.com/sitemap.xml --sitemap

By default, successful requests are not printed to the terminal. To see all urls with a 200 response add the --verbose flag.

> pyanchor https://mysite.com/sitemap.xml --sitemap --verbose

Example Gif

But wait, there's more...

To integrate PyAnchor into your application, you can import the LinkResults class. LinkResults requires a URL.

Example:

>>> from pyanchor.link_checker import LinkResults
>>> r = LinkResults("https://mysite.com/")
>>> r.results
{200: ["https://mysite.com/about/", "https://mysite.com/contact/"], 500: ["https://mysite.com/doh!/"]}

As you can see the results attribute is a dictionary containing all response codes returned as a dictionary key, with a list of URLs that achieve that response code as the dictionary value.

What's next?

The plan for PyAnchor is to add further analysis of anchor tags, such as missing attributes and security considerations.

After that, who knows? 🤷‍♂️

Feedback

If you find a bug, please file an issue.

If you have feature requests, please file an issue and use the appropriate label.

Support

If you would like to show your support for the project, I would be very grateful if you would donate to a charity close to my heart, Walk AS One.

And if you would prefer to donate to me personally instead, you can sponsor me on Github? 🤓

Contributors

Thank you to:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyanchor-0.4.tar.gz (147.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyanchor-0.4-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file pyanchor-0.4.tar.gz.

File metadata

  • Download URL: pyanchor-0.4.tar.gz
  • Upload date:
  • Size: 147.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for pyanchor-0.4.tar.gz
Algorithm Hash digest
SHA256 47132c5deed7a4e043f38950c97411fefa27ac4b6089ee97cbd78edf85efc136
MD5 a64f4af1eb4b41bda29825699efea259
BLAKE2b-256 bf6a5ba271cacd58e3e3b20fd0274b27607a226063b64197113ff99673808681

See more details on using hashes here.

File details

Details for the file pyanchor-0.4-py3-none-any.whl.

File metadata

  • Download URL: pyanchor-0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for pyanchor-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f276692c0e840b5b8bed203a3ffbab7e8b8066bc7835f6f980f17f3827fe76f0
MD5 0dab7fb2cc27e605c6feadc8d4889148
BLAKE2b-256 c4e609f561166a145db2b4f89157dce02b84e5b7fc274751b0b765ec3c178171

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page