Simple sitemap (https://www.sitemaps.org) generator as command line tool.
It generates sitemap for the basic URL with a specified max depth and using parallel workers:
- accepts start URL as argument
- recursively navigates by site pages in parallel
- extracts page URLs only from
<a>elements and take in account<base>element if declared
Command flags are:
- -h show help of usage
- -v shows current version of the app
- -log-level=
namelevel of issuing log messages (error, warn, info, debug) - -timeout=
durationallowable timeout for each URL reading (valid duration units are 'ms', 's', 'm') - -max-retries=
nummax retries for each URL reading - -max-redirects=
nummax redirects when server response with redirect HTTP response - -parallel=
numnumber of parallel workers to navigate through site - -max-depth=
nummax depth of url navigation recursion - -output-file=
path-to-fileoutput file path
- Download from the repository:
git clone git@github.com:mike-jc/service-scim.gitor download a ZIP archive from https://github.com/mike-jc/service-scim
- Build an executable file
cd service-scim
go mod tidy
sh build.sh- Run a command
The mandatory command argument is URL from which the site is started to be scanned.
./build/siteGenerator -parallel=10 --output-file=sitemap.xml https://www.sitemaps.org/ cd service-scim
go test -timeout 3s ./...- When halt the app (e.g. by Ctrl+C), write all already found links to sitemap file. Currently it's being written at the end of the traversing
- Use a docker to run a command (Dockerfile, docker-compose.yml)
- Use third-party libraries:
- For CLI app in Go: Cobra (https://github.com/spf13/cobra), Viper (https://github.com/spf13/viper).
- For logging: Zap (https://github.com/uber-go/zap)
- Better coverage of unit tests (not only happy flow)