Pings a URL and checks the HTTP status code. Based on the status code, prints the URL and status code in color (on CI). This is useful in finding broken links from the list of provided URLs
This is how it works:
-
If the status code is less than 300, prints the provided URL in green color and adds the URL and status code to the report file.
-
If the status code is 301 or 302, prints the original/provided URL in blue color, adds the URL and status code to the report file. Pings the redirected URL after that
-
If the status code is greater than 400, prints the original/provided URL in red color, adds the URL and status code to the report file.
-
The project also has Mobile linkchecker. This will add a user agent to the request property and make sure that mobile URLs are working as expected.
-
The connection timeout and readtimeout for each URL is 10 seconds. It means that, the same number URLs could finish faster against one server and could be slower on another.
-
For execution, create a LinkChecker.csv file and add a header "URLS" in the first column. After that add as many URLs as you want.
-
Sample output is available here: https://github.com/amitkc1/LinkChecker/blob/master/images/sampleOutput.png
Usage:
This program can be executed from IDE or CI. This is a single threaded linkchecker, I will be committing changes in near future to make it multithreaded. At the end of execution, this will create a text report.
Features:
- Creates a report that includes response code for each URL. This makes it easy to analyze the report and find out the failures.
- Customized messages for errors
- Color coding to spot failures easily
- Allows users to set mobile user agent.