A fast, concurrent web crawler written in Go that recursively crawls websites, respects robots.txt, supports configurable redirects and rate limiting, extracts structured page information, and exports deterministic JSON reports.
- Features
- Installation
- Usage
- Output
- Project Structure
- How It Works
- Development
- Contributing
- Roadmap
- Documentation
- License
- Recursive crawling within a single domain
- Configurable concurrency limit
- Configurable maximum page limit
- Configurable crawl depth
- Configurable request delay
- Configurable User-Agent
- Configurable request rate limiting
- Configurable HTTP redirect handling
- URL normalization to avoid duplicate crawls
- Automatic retry with exponential backoff for transient HTTP failures
robots.txtsupport- Internal and external link classification
- Crawl statistics and summary reporting
- Structured logging using
log/slog - Thread-safe crawling using goroutines, mutexes, and wait groups
- Structured page extraction including:
- URL
- Heading
- First paragraph
- Outgoing links
- Image URLs
- Deterministic JSON report generation
git clone https://github.com/shubh1855/Gotcha.git
cd Gotchago mod downloadgo build -o gotcha .Run the crawler:
gotcha [flags] <url>Show all available options:
gotcha --helpCrawl a website using the default configuration:
gotcha https://example.comLimit concurrency:
gotcha --concurrency 10 https://example.comLimit the number of pages:
gotcha --pages 200 https://example.comLimit crawl depth:
gotcha --depth 3 https://example.comAdd a delay between requests:
gotcha --delay 500ms https://example.comRate limit HTTP requests:
gotcha --rate 5 https://example.comUse a custom User-Agent:
gotcha --user-agent "MyCrawler/1.0" https://example.comEnable verbose logging:
gotcha --verbose https://example.comPrint version information:
gotcha --versionExample using multiple options:
gotcha \
--concurrency 10 \
--pages 200 \
--depth 3 \
--delay 500ms \
--user-agent "MyCrawler/1.0" \
--verbose \
https://example.com| Flag | Description | Default |
|---|---|---|
-c, --concurrency |
Maximum concurrent requests | 5 |
-p, --pages |
Maximum pages to crawl | 100 |
--depth |
Maximum crawl depth (-1 = unlimited) |
-1 |
-u, --user-agent |
HTTP User-Agent | Gotcha/1.0 (...) |
-d, --delay |
Fixed delay between requests | 0s |
-r, --max-redirects |
Maximum redirects to follow | 10 |
--rate |
Maximum HTTP requests per second (0 disables rate limiting) |
0 |
-v, --verbose |
Enable debug logging | false |
-V, --version |
Print version information | false |
Starting crawl of https://example.com
Pages crawled : 15
Pages skipped : 2
Robots skipped: 1
Failed fetches: 0
Internal links: 37
External links: 12
JSON report written to report.json
After crawling completes, a report.json file is generated containing the extracted page information.
Each record contains:
{
"url": "https://example.com",
"heading": "Example Domain",
"first_paragraph": "This domain is for use in illustrative examples in documents.",
"outgoing_links": [],
"image_urls": []
}.
├── .github/
│ └── workflows/
│ ├── ci.yml
│ └── release.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── config.go
├── crawler.go
├── errors.go
├── extract_content.go
├── extract_page.go
├── fetch.go
├── json_report.go
├── logger.go
├── main.go
├── normalize_url.go
├── parser.go
├── robots.go
├── stats.go
└── version.go
- Start crawling from the provided URL.
- Respect the site's
robots.txtrules. - Normalize URLs to prevent duplicate visits.
- Crawl pages recursively while remaining within the same domain.
- Retry transient HTTP failures automatically.
- Extract structured page information.
- Classify internal and external links.
- Store page data in memory.
- Generate a deterministic JSON report.
Run tests:
go test ./...Run static analysis:
go vet ./...Format the code:
gofmt -w .Build:
go build .Contributions are welcome! Whether it's a bug fix, a new feature, documentation improvements, or performance optimizations, your help is appreciated.
Clone the repository and install dependencies:
git clone https://github.com/shubh1855/Gotcha.git
cd Gotcha
go mod download- Create a new branch from
main.
git checkout -b feature/my-feature-
Make your changes.
-
Run the quality checks.
gofmt -w .
go vet ./...
go test ./...- Commit your changes using a descriptive commit message.
Examples:
feat(crawler): add crawl depth support
fix(fetch): handle redirect loops
docs: update README
- Push your branch and open a Pull Request.
Before opening a Pull Request, please ensure:
- Code is formatted with
gofmt -
go vet ./...passes -
go test ./...passes - Documentation has been updated if required
-
CHANGELOG.mdhas been updated for user-facing changes
If you encounter a bug or have a feature request, please open a GitHub Issue with:
- A clear description of the problem
- Steps to reproduce (for bugs)
- Expected behavior
- Relevant logs or screenshots (if applicable)
- Smarter duplicate URL detection
- Sitemap generation
- CSV export
- Markdown export
- Benchmark suite
- Expanded integration test coverage
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.