A concurrent web crawler built in Go. Crawls web pages starting from seed URLs, respects robots.txt, extracts links, and stores page content in PostgreSQL — all coordinated via Redis.
initurls.txt --> Redis Queue (list) --> doCrawl() goroutines (up to 50)
^ |
| +----+-------+
| | |
| robots.txt? Fetch page
| | |
| | Extract links
| | (resolve + fragment strip)
| | |
| | Save to PostgreSQL
| | |
+------------------+ Mark visited in Redis (TTL: 7d)
- Concurrent crawling with rate limiting and robots.txt compliance.
- URL fragments (
#section) are stripped during link resolution to avoid redundant crawls of the same page. - Redis is used for both the crawl frontier (queue) and visited URL deduplication.
- PostgreSQL stores crawled page content with upsert-based deduplication.
# Clone and enter the repo
git clone <repo-url> && cd gocrawl
# Edit seed URLs (optional)
# vi cmd/main/initurls.txt
# Start everything (Redis + Postgres + app)
make up
# Follow logs
make logs
# Stop
make downThe crawler will start processing URLs and storing results in PostgreSQL automatically.
# Ensure Redis and Postgres are running (Docker)
make redis postgres
# Build the binary
make localbuild
# or: go build -C cmd/main -o ../../gocrawl .
# Run
./gocrawlAll configuration is via environment variables:
| Variable | Default | Description |
|---|---|---|
REDIS_HOST |
localhost |
Redis server host |
REDIS_PORT |
6379 |
Redis server port |
DATABASE_URL |
postgres://user:pass@localhost:5432/mydb |
PostgreSQL connection string |
CREATE TABLE t_web_page_details (
url VARCHAR(2048) PRIMARY KEY,
crawled_at TIMESTAMP NOT NULL,
content TEXT NOT NULL,
processed BOOLEAN NOT NULL DEFAULT FALSE
);# Stop and remove containers + volumes (wipes all data)
make clean
# or: docker compose down -v
# Remove local binary
rm -f gocrawl| Target | Description |
|---|---|
up |
Start all services in detached mode |
down |
Stop all services |
rebuild |
Full rebuild: wipe volumes, rebuild images, start, tail logs |
logs |
Tail container logs |
clean |
Stop and remove containers + volumes |
redis |
Start only Redis |
postgres |
Start only Postgres |
localbuild |
Build the Go binary locally (output: ./gocrawl) |