A minimal Go service that:
- Fetches a URL
- Extracts metadata (title, description, og: tags, headings, main text)
- Returns lightweight classification (product/news/blog/other)
- Extracts top topics (keywords) via a simple frequency-based approach
- Exposes HTTP endpoints for single URL and batch crawl
- Ready for Docker deployment
GET /health– health probePOST /crawl– crawl a single URL
Body:{"url":"https://example.com"}
Response: metadata + classification + topicsPOST /crawl/batch– crawl multiple URLs concurrently
Body:{"urls":["https://example.com","https://cnn.com"]}
Response: map of url -> result/error
# requires Go 1.21+
make deps
make run
# in a new shell:
curl -s localhost:8080/health
curl -s -X POST localhost:8080/crawl -H 'Content-Type: application/json' -d '{"url":"https://www.cnn.com/2025/09/23/tech/google-study-90-percent-tech-jobs-ai"}' | jq .
curl -s -X POST localhost:8080/crawl -H 'Content-Type: application/json' -d '{"url":"https://example.com"}' | jq .
curl -s -X POST localhost:8080/crawl/batch -H 'Content-Type: application/json' -d '{"urls":["https://example.com","https://cnn.com"]}' | jq .Run the live URL tests (may be flaky due to blocking/network):
go test ./... -tags=integration -vor
make testmake build # builds ./bin/server- CLI:
go run ./cmd/cli --input examples/urls.csv --output examples/output.ndjson - API (multipart):
POST /crawl/uploadwithfile=@examples/urls.csvreturns NDJSON stream.
See examples/ folder.
Run the example files from the root
sh examples/run_example.shOutout:
2025/11/01 11:17:11 [INFO] server listening on :8080
Wrote examples/output.ndjson
2025/11/01 11:17:14 [INFO] POST /crawl/upload 774.451354ms
Wrote examples/upload_output.ndjson
docker build -t brightedge-go-crawler:local .
docker run --rm -p 8080:8080 brightedge-go-crawler:local- This is a respectful, single-URL fetcher, not a full web spider: it does not follow links.
- Classification is deliberately simple and explainable (rule-based signals). In production, you'd enhance it with learned models and site-specific features.
- Topic extraction is frequency-based with a stopword list; switch to TF-IDF or RAKE for better results.
- Timeouts, retries, and size caps keep the service robust for demo purposes.
.
├── cmd
│ └── server
│ └── main.go
├── internal
│ ├── classifier
│ │ └── classifier.go
│ ├── crawler
│ │ └── crawler.go
│ ├── models
│ │ └── types.go
│ └── parser
│ └── parser.go
├── pkg
│ └── logger
│ └── logger.go
├── go.mod
├── Makefile
├── Dockerfile
└── README.md
curl -s -X POST localhost:8080/crawl \
-H 'Content-Type: application/json' \
-d '{"url":"https://www.cnn.com/"}' | jq .- CLI:
go run ./cmd/cli --input examples/urls.csv --output examples/output.ndjson - API (multipart):
POST /crawl/uploadwithfile=@examples/urls.csvreturns NDJSON stream.