{"id":36776525,"url":"https://github.com/alonecandies/golwarc","last_synced_at":"2026-01-12T13:12:01.721Z","repository":{"id":330886110,"uuid":"1119543214","full_name":"alonecandies/golwarc","owner":"alonecandies","description":"All-in-One crawlers for Golang","archived":false,"fork":false,"pushed_at":"2025-12-29T09:43:57.000Z","size":2578,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-31T11:26:33.744Z","etag":null,"topics":["crawler","crawling","go","golang","scraper","scraping"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alonecandies.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"AUDIT_REPORT.md","citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-19T12:46:54.000Z","updated_at":"2025-12-28T20:04:31.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/alonecandies/golwarc","commit_stats":null,"previous_names":["alonecandies/golwarc"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/alonecandies/golwarc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alonecandies%2Fgolwarc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alonecandies%2Fgolwarc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alonecandies%2Fgolwarc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alonecandies%2Fgolwarc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alonecandies","download_url":"https://codeload.github.com/alonecandies/golwarc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alonecandies%2Fgolwarc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28338996,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crawler","crawling","go","golang","scraper","scraping"],"created_at":"2026-01-12T13:12:00.994Z","updated_at":"2026-01-12T13:12:01.710Z","avatar_url":"https://github.com/alonecandies.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Golwarc - Go Web Crawler Master\n\n[![CI](https://github.com/alonecandies/golwarc/actions/workflows/ci.yml/badge.svg)](https://github.com/alonecandies/golwarc/actions/workflows/ci.yml)\n[![Go Version](https://img.shields.io/badge/Go-1.25-blue.svg)](https://golang.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA comprehensive Go-based crawler master framework with multiple database clients, caching systems, message queues, and various crawler implementations.\n\n## Architecture\n\n![Golwarc Architecture](docs/architecture.png)\n\nThe architecture follows a clean dependency injection pattern:\n\n- **main.go** - Entry point that initializes the DI container\n- **inject/inject.go** - Dependency injection container that conditionally initializes all packages\n- **services/** - Business logic layer that receives injected dependencies\n- **Packages** - Independent modules for cache, database, crawlers, message queues, etc.\n\nFor detailed architecture documentation, see [ARCHITECTURE.md](ARCHITECTURE.md).\n\n## Documentation\n\nComprehensive documentation is available to help you understand and use Golwarc effectively:\n\n- **[Architecture](ARCHITECTURE.md)** - Detailed architecture and dependency injection pattern explanation\n- **[Performance](PERFORMANCE.md)** - Performance tips, optimization strategies, and benchmarks\n- **[Security](SECURITY.md)** - Security best practices and guidelines\n- **[Contributing](CONTRIBUTING.md)** - Guidelines for contributing to the project\n- **[Changelog](CHANGELOG.md)** - Version history and release notes\n- **[Troubleshooting](TROUBLESHOOTING.md)** - Common issues and solutions\n\n## Features\n\n### 🗄️ Database Support\n\n- **MySQL** - Full GORM integration with connection pooling\n- **PostgreSQL** - GORM-based with transaction support\n- **ClickHouse** - Optimized for analytical workloads\n- **BigTable** - Google Cloud BigTable client\n\n### 💾 Caching\n\n- **LRU Cache** - In-memory LRU cache with configurable size\n- **Redis** - Full-featured Redis client with TTL, JSON support, and atomic operations\n\n### ⚙️ Configuration\n\n- **Viper** - YAML/JSON configuration with environment variable overrides\n- Structured configuration for all components\n- Hot-reload support\n\n### 📨 Message Queues\n\n- **Kafka** - Producer and consumer with batch operations\n- **RabbitMQ** - Full-featured client with exchange/queue management\n\n### 🔄 Workflow Orchestration\n\n- **Temporal** - Workflow and activity management\n- Signal and query support\n- Worker creation and management\n\n### 🕷️ Crawler Implementations\n\n#### Static Content Crawlers\n\n- **Colly** - Fast and elegant scraper framework\n- **Spider** - Custom crawler using goquery/cascadia\n- **Soup** - Simple HTML parser\n\n#### Dynamic Content Crawlers (JavaScript Support)\n\n- **Selenium** - WebDriver-based browser automation\n- **Playwright** - Multi-browser support (Chromium, Firefox, WebKit)\n- **Puppeteer** - Chrome DevTools Protocol via chromedp\n- **Ferret** - Declarative web scraping with FQL\n\n### 📊 Models\n\nPre-built models for common scraping scenarios:\n\n- **Page** - Web page data\n- **Product** - E-commerce products\n- **Article** - News articles and blog posts\n\n## Installation\n\n```bash\ngit clone https://github.com/alonecandies/golwarc\ncd golwarc\ngo mod download\n```\n\n## Configuration\n\nCopy the example configuration file and customize it:\n\n```bash\ncp configs/config.example.yaml configs/config.yaml\n```\n\nEdit `configs/config.yaml` with your database credentials, cache settings, and other configurations.\n\n## Quick Start\n\n### 1. Initialize Logger\n\n```go\npackage main\n\nimport \"github.com/alonecandies/golwarc/logger\"\n\nfunc main() {\n    // Initialize logger\n    logger.InitDefaultLogger()\n    defer logger.Sync()\n\n    log := logger.GetLogger()\n    log.Info(\"Hello from Golwarc!\")\n}\n```\n\n### 2. Load Configuration\n\n```go\nimport \"github.com/alonecandies/golwarc/configs\"\n\nconfig, err := configs.LoadConfig(\"configs/config.yaml\")\nif err != nil {\n    panic(err)\n}\n```\n\n### 3. Use Cache\n\n```go\nimport \"github.com/alonecandies/golwarc/cache\"\n\n// LRU Cache\nlruCache, err := cache.NewLRUCache(1000)\nlruCache.Set(\"key\", \"value\")\nvalue, exists := lruCache.Get(\"key\")\n\n// Redis Cache\nredisClient, err := cache.NewRedisClient(cache.RedisConfig{\n    Addr:     \"localhost:6379\",\n    Password: \"\",\n    DB:       0,\n})\nredisClient.Set(\"key\", \"value\", 10*time.Minute)\n```\n\n### 4. Database Operations\n\n```go\nimport \"github.com/alonecandies/golwarc/database\"\n\n// MySQL\nmysqlClient, err := database.NewMySQLClient(database.MySQLConfig{\n    Host:     \"localhost\",\n    Port:     3306,\n    User:     \"root\",\n    Password: \"password\",\n    Database: \"golwarc\",\n})\ndefer mysqlClient.Close()\n\n// Auto-migrate models\nmysqlClient.Migrate(\u0026models.Page{}, \u0026models.Product{}, \u0026models.Article{})\n```\n\n### 5. Web Crawling Examples\n\n#### Using Colly (Static Content)\n\n```go\nimport \"github.com/alonecandies/golwarc/crawlers\"\n\nclient := crawlers.NewDefaultCollyClient()\n\nclient.OnHTML(\"h1\", func(e *colly.HTMLElement) {\n    fmt.Println(\"Title:\", e.Text)\n})\n\nclient.OnHTML(\"a[href]\", func(e *colly.HTMLElement) {\n    link := e.Attr(\"href\")\n    fmt.Println(\"Link:\", link)\n    e.Request.Visit(link)\n})\n\nclient.Visit(\"https://example.com\")\nclient.Wait()\n```\n\n#### Using Playwright (Dynamic Content)\n\n```go\nimport \"github.com/alonecandies/golwarc/crawlers\"\n\nclient, err := crawlers.NewPlaywrightClient(crawlers.PlaywrightConfig{\n    BrowserType: \"chromium\",\n    Headless:    true,\n})\ndefer client.Close()\n\nclient.Navigate(\"https://example.com\")\nclient.Click(\"button#load-more\")\nclient.WaitForSelector(\".dynamic-content\")\n\ncontent, err := client.GetContent()\nfmt.Println(content)\n```\n\n#### Using Ferret FQL (Declarative)\n\n```go\nimport \"github.com/alonecandies/golwarc/crawlers\"\n\nclient, err := crawlers.NewDefaultFerretClient()\n\n// Extract all links\nlinks, err := client.ExtractLinks(\"https://example.com\")\n\n// Extract products\nproducts, err := client.ExampleExtractProducts(\"https://shop.example.com\")\n```\n\n### 6. Message Queue Operations\n\n#### Kafka\n\n```go\nimport \"github.com/alonecandies/golwarc/message-queue\"\n\nproducer := messagequeue.NewKafkaProducer(messagequeue.KafkaProducerConfig{\n    Brokers: []string{\"localhost:9092\"},\n    Topic:   \"crawl-results\",\n})\ndefer producer.Close()\n\nproducer.Produce(ctx, []byte(\"key\"), []byte(\"message\"))\n```\n\n#### RabbitMQ\n\n```go\nimport \"github.com/alonecandies/golwarc/message-queue\"\n\nclient, err := messagequeue.NewRabbitMQClient(messagequeue.RabbitMQConfig{\n    URL: \"amqp://guest:guest@localhost:5672/\",\n})\ndefer client.Close()\n\nclient.DeclareQueue(\"tasks\", true)\nclient.Publish(ctx, \"tasks\", []byte(\"task data\"))\n```\n\n### 7. Temporal Workflow\n\n```go\nimport \"github.com/alonecandies/golwarc/libs\"\n\ntemporalClient, err := libs.NewTemporalClient(libs.TemporalConfig{\n    HostPort:  \"localhost:7233\",\n    Namespace: \"default\",\n})\ndefer temporalClient.Close()\n\n// Start a workflow\nrun, err := temporalClient.StartWorkflow(ctx, \"workflow-id\", \"task-queue\", \"workflowType\", args)\n```\n\n## Usage Examples\n\n### Complete Crawling Pipeline\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"time\"\n\n    \"github.com/alonecandies/golwarc\"\n    \"github.com/alonecandies/golwarc/cache\"\n    \"github.com/alonecandies/golwarc/configs\"\n    \"github.com/alonecandies/golwarc/crawlers\"\n    \"github.com/alonecandies/golwarc/database\"\n    \"github.com/alonecandies/golwarc/models\"\n)\n\nfunc main() {\n    // Initialize logger\n    golwarc.InitDefaultLogger()\n    defer golwarc.Sync()\n\n    // Load config\n    config, _ := configs.LoadConfig(\"configs/config.yaml\")\n\n    // Setup cache\n    redisClient, _ := cache.NewRedisClient(cache.RedisConfig{\n        Addr:     config.Cache.Redis.Addr,\n        Password: config.Cache.Redis.Password,\n        DB:       config.Cache.Redis.DB,\n    })\n    defer redisClient.Close()\n\n    // Setup database\n    mysqlClient, _ := database.NewMySQLClient(database.MySQLConfig{\n        Host:     config.Database.MySQL.Host,\n        Port:     config.Database.MySQL.Port,\n        User:     config.Database.MySQL.User,\n        Password: config.Database.MySQL.Password,\n        Database: config.Database.MySQL.Database,\n    })\n    defer mysqlClient.Close()\n\n    // Migrate models\n    mysqlClient.Migrate(\u0026models.Page{})\n\n    // Create crawler\n    crawler := crawlers.NewDefaultCollyClient()\n\n    crawler.OnHTML(\"title\", func(e *colly.HTMLElement) {\n        // Check cache\n        cached, _ := redisClient.Exists(e.Request.URL.String())\n        if cached {\n            return\n        }\n\n        // Save to database\n        page := \u0026models.Page{\n            URL:    e.Request.URL.String(),\n            Title:  e.Text,\n            Status: 200,\n        }\n        mysqlClient.Create(page)\n\n        // Cache the result\n        redisClient.Set(e.Request.URL.String(), \"processed\", 24*time.Hour)\n\n        fmt.Printf(\"Saved: %s\\n\", e.Text)\n    })\n\n    crawler.Visit(\"https://example.com\")\n    crawler.Wait()\n}\n```\n\n## Testing\n\n```bash\n# Run all tests\ngo test ./tests/...\n\n# Run with verbose output\ngo test -v ./tests/...\n\n# Run with coverage\ngo test -cover ./tests/...\n\n# Run specific test package\ngo test ./tests/cache/\ngo test ./tests/configs/\ngo test ./tests/models/\n```\n\n## Project Structure\n\n```\ngolwarc/\n├── cache/              # Cache implementations\n│   ├── lru.go\n│   └── redis.go\n├── configs/            # Configuration management\n│   ├── config.go\n│   └── config.example.yaml\n├── crawlers/           # Crawler implementations\n│   ├── colly.go\n│   ├── spider.go\n│   ├── soup.go\n│   ├── selenium.go\n│   ├── playwright.go\n│   ├── puppeteer.go\n│   └── ferret.go\n├── database/           # Database clients\n│   ├── mysql.go\n│   ├── postgresql.go\n│   ├── clickhouse.go\n│   └── bigtable.go\n├── docker/             # Docker configuration\n│   ├── Dockerfile\n│   └── docker-compose.yaml\n├── libs/               # Third-party integrations\n│   └── temporal.go\n├── logger/             # Logging configuration\n│   └── logger.go\n├── message-queue/      # Message queue clients\n│   ├── kafka.go\n│   └── rabbitmq.go\n├── models/             # Data models\n│   ├── page.go\n│   ├── product.go\n│   └── article.go\n├── scripts/            # Development scripts\n│   └── dev.sh\n├── tests/              # Test suite\n│   ├── cache/\n│   │   └── cache_test.go\n│   ├── configs/\n│   │   └── config_test.go\n│   └── models/\n│       └── models_test.go\n├── .env.example        # Environment variables template\n├── config.example.yaml # Configuration template\n├── go.mod\n├── go.sum\n├── main.go             # Demo application\n└── README.md\n```\n\n## External Dependencies\n\n### Browser Automation Tools\n\nFor Selenium, Playwright, and Puppeteer clients to work, you need:\n\n#### Selenium\n\n- Download ChromeDriver or GeckoDriver\n- Or use a remote Selenium server (e.g., Selenium Grid)\n\n#### Playwright\n\n```bash\ngo run github.com/playwright-community/playwright-go/cmd/playwright install\n```\n\n#### Puppeteer (chromedp)\n\n- Requires Chrome/Chromium installed on the system\n\n### Database Services\n\nEnsure you have the following services running:\n\n- MySQL (port 3306)\n- PostgreSQL (port 5432)\n- ClickHouse (port 9000)\n- Redis (port 6379)\n- Kafka (port 9092)\n- RabbitMQ (port 5672)\n- Temporal (port 7233)\n\nUse Docker Compose for easy setup:\n\n```yaml\nversion: \"3.8\"\nservices:\n  mysql:\n    image: mysql:8.0\n    ports:\n      - \"3306:3306\"\n    environment:\n      MYSQL_ROOT_PASSWORD: password\n      MYSQL_DATABASE: golwarc\n\n  redis:\n    image: redis:7-alpine\n    ports:\n      - \"6379:6379\"\n\n  kafka:\n    image: confluentinc/cp-kafka:latest\n    ports:\n      - \"9092:9092\"\n\n  # Add other services as needed\n```\n\n## Testing\n\n```bash\n# Run all tests\ngo test ./...\n\n# Run with coverage\ngo test -coverprofile=coverage.out ./...\ngo tool cover -html=coverage.out\n```\n\n## Performance Tips\n\n1. **Use connection pooling** - All database clients have built-in connection pooling\n2. **Enable caching** - Use Redis to cache frequently accessed data\n3. **Batch operations** - Use batch inserts for better throughput\n4. **Rate limiting** - Configure delays in crawlers to avoid overwhelming targets\n5. **Concurrent crawling** - Use Colly's async mode or Spider's concurrency settings\n\n## FAQ\n\n### General Questions\n\n**Q: What Go version is required?**  \nA: Go 1.25 or later is required.\n\n**Q: Can I use this in production?**  \nA: Yes! Golwarc is production-ready with comprehensive testing and error handling.\n\n**Q: Which crawler should I use?**  \nA:\n\n- **Static sites**: Use Colly (fastest, most efficient)\n- **JavaScript-heavy sites**: Use Playwright or Puppeteer\n- **Complex scraping logic**: Use Ferret with FQL\n- **Browser compatibility testing**: Use Selenium\n\n**Q: Do I need all the external services (Redis, MySQL, etc.)?**  \nA: No! Golwarc uses conditional initialization. Only configure the services you need.\n\n### Configuration\n\n**Q: How do I override config with environment variables?**  \nA: Use the `GOLWARC_` prefix:\n\n```bash\nexport GOLWARC_DATABASE_MYSQL_HOST=production.db\nexport GOLWARC_CACHE_REDIS_ADDR=redis.example.com:6379\n```\n\n**Q: Can I use environment variables exclusively?**  \nA: Yes, either via `.env` file or export commands. The DI container will use defaults if config file is missing.\n\n### Database\n\n**Q: Can I use multiple databases simultaneously?**  \nA: Yes! Configure all databases you need in `config.yaml` and they'll all be initialized.\n\n**Q: How do I migrate to a new database schema?**  \nA: Use GORM's AutoMigrate:\n\n```go\ncontainer.MySQLClient.Migrate(\u0026models.NewModel{})\n```\n\n**Q: What about database connection pooling?**  \nA: All database clients have connection pooling pre-configured with sensible defaults (10 idle, 100 max open connections).\n\n### Crawling\n\n**Q: How do I avoid getting blocked while crawling?**  \nA:\n\n1. Add delays between requests\n2. Rotate user agents\n3. Use proxies (configure in crawler settings)\n4. Respect robots.txt\n5. Implement rate limiting\n\n**Q: Can I crawl sites that require login?**  \nA: Yes, use Playwright or Selenium to handle authentication flows.\n\n**Q: How do I handle AJAX/dynamic content?**  \nA: Use Playwright, Puppeteer, or Ferret instead of Colly/Soup.\n\n### Caching\n\n**Q: When should I use LRU vs Redis cache?**  \nA:\n\n- **LRU**: Single instance, development, simple caching needs\n- **Redis**: Distributed systems, production, shared cache across services\n\n**Q: Can I use both caches together?**  \nA: Yes! Use LRU as L1 cache and Redis as L2 for multi-tier caching.\n\n### Testing\n\n**Q: Why do tests skip?**  \nA: Tests skip when external services aren't available. Use `make docker-up` to start all services.\n\n**Q: How do I run only unit tests?**  \nA: Unit tests that don't require external services will run:\n\n```bash\ngo test ./tests/configs/\ngo test ./tests/models/\n```\n\n### Performance\n\n**Q: How many concurrent crawlers can I run?**  \nA: Depends on your resources. Start with 5-10 and monitor CPU/memory. Use message queues (Kafka/RabbitMQ) for distributed crawling.\n\n**Q: How do I improve crawling speed?**  \nA:\n\n1. Use Colly's async mode\n2. Increase concurrency settings\n3. Enable caching to avoid re-crawls\n4. Use connection pooling\n5. Batch database inserts\n\n## Troubleshooting\n\nFor common issues and solutions, see [TROUBLESHOOTING.md](TROUBLESHOOTING.md).\n\nQuick links:\n\n- [Database connection issues](TROUBLESHOOTING.md#database-connection-issues)\n- [Crawler issues](TROUBLESHOOTING.md#crawler-issues)\n- [Cache issues](TROUBLESHOOTING.md#cache-issues)\n- [Test issues](TROUBLESHOOTING.md#test-issues)\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nMIT License - see LICENSE file for details\n\n## Acknowledgments\n\n- [Colly](https://github.com/gocolly/colly) - Fast web scraping framework\n- [goquery](https://github.com/PuerkitoBio/goquery) - jQuery-like HTML parsing\n- [Playwright](https://github.com/playwright-community/playwright-go) - Browser automation\n- [chromedp](https://github.com/chromedp/chromedp) - Chrome DevTools Protocol\n- [Ferret](https://github.com/MontFerret/ferret) - Declarative web scraping\n- [GORM](https://gorm.io/) - ORM library for Go\n- [Viper](https://github.com/spf13/viper) - Configuration management\n- [Zap](https://github.com/uber-go/zap) - Fast structured logging\n\n## Support\n\nFor issues, questions, or contributions, please visit the [GitHub repository](https://github.com/alonecandies/golwarc).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falonecandies%2Fgolwarc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falonecandies%2Fgolwarc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falonecandies%2Fgolwarc/lists"}