{"id":20830646,"url":"https://github.com/endlesstrax/pyanchor","last_synced_at":"2025-04-05T05:04:41.410Z","repository":{"id":43388395,"uuid":"283314053","full_name":"EndlessTrax/pyanchor","owner":"EndlessTrax","description":"Find your broken links, so users don't.  ","archived":false,"fork":false,"pushed_at":"2025-02-02T00:04:53.000Z","size":581,"stargazers_count":67,"open_issues_count":5,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-29T04:07:00.835Z","etag":null,"topics":["anchor-tags","cli","dead-links","hacktoberfest","link-checker","python","python3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pyanchor/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EndlessTrax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"EndlessTrax"}},"created_at":"2020-07-28T19:57:05.000Z","updated_at":"2025-03-22T18:47:49.000Z","dependencies_parsed_at":"2024-03-20T20:01:12.731Z","dependency_job_id":"83bcdb6a-98d0-439a-801e-6a1d9d0f824d","html_url":"https://github.com/EndlessTrax/pyanchor","commit_stats":{"total_commits":155,"total_committers":8,"mean_commits":19.375,"dds":0.0903225806451613,"last_synced_commit":"80c8c12dfde6e0a3d20699e92d699f95bee61556"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EndlessTrax%2Fpyanchor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EndlessTrax%2Fpyanchor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EndlessTrax%2Fpyanchor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EndlessTrax%2Fpyanchor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EndlessTrax","download_url":"https://codeload.github.com/EndlessTrax/pyanchor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289424,"owners_count":20914464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anchor-tags","cli","dead-links","hacktoberfest","link-checker","python","python3"],"created_at":"2024-11-17T23:25:19.619Z","updated_at":"2025-04-05T05:04:41.386Z","avatar_url":"https://github.com/EndlessTrax.png","language":"Python","funding_links":["https://github.com/sponsors/EndlessTrax","https://github.com/sponsors/EndlessTrax)?"],"categories":[],"sub_categories":[],"readme":"# PyAnchor\n\n[![PyPI version](https://badge.fury.io/py/pyanchor.svg)](https://badge.fury.io/py/pyanchor)\n![GitHub](https://img.shields.io/github/license/endlesstrax/pyanchor)\n\nDead links are an annoyance for websites with an extensive amount of content. A side from the\nnegative impact on SEO, dead links are an annoyance for any user that clicks on one.\n\nPyAnchor is primarily for checking the HTTP response on all links on a page. You can integrate it\ninto your development workflow so that users never see a 404 in the first place.\n\n## Install\n\n\u003e Requires Python 3.8 and above.\n\nIt is recommended that you install this package in a virtual or isoloated environment. The easiest way to do this \nis with pipx.\n\n```shell\npipx install pyanchor\n```\n\nAlternatively, you can install it with pip into your virtual environment:\n\nMacOS / Linux:\n\n```shell\npython3 -m pip install pyanchor\n```\n\nWindows:\n\n```pwsh\npython -m pip install pyanchor\n```\n\n## Using the CLI\n\nThe CLI can be invoked with the `pyanchor` command. A URL **must** be provided unless it's the help page.\n\nTo get the help page:\n\n```shell\npyanchor --help\n```\n\n![Example Gif](/assets/example-help.gif)\n\nBasic example for a single page:\n\n\u003e Note: all provided URLs must include a valid HTTP scheme.\n\n```shell\npyanchor https://mysite.com/\n```\n\n![Example Gif](/assets/example-single-page.gif)\n\nIf you want to check all links on a website, and not just a single page, a `sitemap.xml` URL may be provided and \nflagged with `--sitemap`.\n\nExample:\n\n```shell\npyanchor https://mysite.com/sitemap.xml --sitemap\n```\n\n![Example Gif](/assets/example-sitemap.gif)\n\nBy default, successful requests are not printed to the terminal. To see all urls with a `200`\nresponse add the `--verbose` flag.\n\n```shell \npyanchor https://mysite.com --verbose\n```\n![Example Gif](/assets/example-single-page-verbose.gif)\n\n```shell\npyanchor https://mysite.com/sitemap.xml --sitemap --verbose\n```\n\n![Example Gif](/assets/example-sitemap-verbose.gif)\n\nIf you wish the output the results to a csv file, instead of to the terminal (default), then you may wish to use \nthe `--output-csv` flag:\n\n```shell\npyanchor https://mysite.com --output-csv output/path/to/file\n```\n\n## But wait, there's more...\n\nTo integrate PyAnchor into your application, you can import the `LinkResults` class. `LinkResults`\nrequires a URL.\n\nExample:\n\n```\n\u003e\u003e\u003e from pyanchor.link_checker import LinkResults\n\u003e\u003e\u003e r = LinkResults(\"https://mysite.com/\")\n\u003e\u003e\u003e r.results\n{200: [\"https://mysite.com/about/\", \"https://mysite.com/contact/\"], 500: [\"https://mysite.com/doh!/\"]}\n```\n\nAs you can see the `results` attribute is a dictionary containing all response codes returned as a\ndictionary key, with a list of URLs that achieve that response code as the dictionary value.\n\n### Analyzing Links\n\nPyAnchor give you the ability to use the `LinkAnalysis` class to check the links in a given URL for unsafe and obsolete attributes.\n\nTo check for obsolete attributes use the `obsolete_attrs` property:\n\n```\n\u003e\u003e\u003e from pyanchor.link_checker import LinkAnalysis\n\u003e\u003e\u003e r = LinkAnalysis(\"https://mysite.com/\")\n\u003e\u003e\u003e r.obsolete_attrs\n{'/about/link-1': ['charset', 'rev'], '/about/link-2': ['name']}\n```\n\nLikewise you can check for unsafe linkes with `unsafe_attrs`:\n\n```\n\u003e\u003e\u003e from pyanchor.link_checker import LinkAnalysis\n\u003e\u003e\u003e r = LinkAnalysis(\"https://mysite.com/\")\n\u003e\u003e\u003e r.unsafe_attrs\n{\u003ca href=\"/about/link-4\" target=\"_blank\"\u003eLink 4\u003c/a\u003e: True, \u003ca href=\"/about/link-5\" rel=\"noreferrer noopener\" target=\"_blank\"\u003eLink 5\u003c/a\u003e: False}\n```\n\nAny link that **does not** include `rel=\"noopener\"` when the `target` attribute is used will return `True`. As in, **it is True that this link is unsafe**. Therfore, links with appropriate attributes will return `False`.\n\n## Feedback\n\nIf you find a bug, please [file an issue](https://github.com/EndlessTrax/pyanchor/issues).\n\nIf you have feature requests, please [file an issue](https://github.com/EndlessTrax/pyanchor/issues)\nand use the appropriate label.\n\n## Support\n\nIf you would like to show your support for the project, \n[you can sponsor me on Github](https://github.com/sponsors/EndlessTrax)? 🤓\n\n## How to Contribute\n\nPlease **raise an issue before making a PR**, so that the issue and implementation can be discussed before you write any code. This will save you time, and increase the chances of your PR being merged without significant changes.\n\nPlease **make PR's on a new branch**, and _not_ on main/master.\n\nPlease **include tests** for any PR's that include code (unless current tests cover your code contribution).\n\nPlease **add documentation** for any new features or flags.\n\n## Contributors\n\nThank you to:\n\n- [Zingzy](https://github.com/Zingzy) for PR [#55](https://github.com/EndlessTrax/pyanchor/pull/55)\n- [mrbazzan](https://github.com/mrbazzan) for PR [#25](https://github.com/EndlessTrax/pyanchor/pull/25)\n- [Icelain](https://github.com/Icelain) for PR [#11](https://github.com/EndlessTrax/pyanchor/pull/11)\n- [wevnasc](https://github.com/wevnasc) for PR [#8](https://github.com/EndlessTrax/pyanchor/pull/8)\n- [muditshamz](https://github.com/muditshamz) for PR [#6](https://github.com/EndlessTrax/pyanchor/pull/6)\n  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendlesstrax%2Fpyanchor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fendlesstrax%2Fpyanchor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendlesstrax%2Fpyanchor/lists"}