Documentation
¶
Index ¶
- Constants
- type Config
- type DB
- type Scraper
- func (s *Scraper) Config() Config
- func (s *Scraper) ExtractLinks(ctx context.Context, targetURL string) ([]string, error)
- func (s *Scraper) OllamaClient() *ollama.Client
- func (s *Scraper) ScoreLinkContent(ctx context.Context, targetURL string) (*models.LinkScore, error)
- func (s *Scraper) Scrape(ctx context.Context, targetURL string) (*models.ScrapedData, error)
- type StorageBackend
Constants ¶
View Source
const (
// UserAgent mimics a recent Chrome browser to avoid being blocked
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
HTTPTimeout time.Duration
OllamaBaseURL string
OllamaModel string
OllamaVisionModel string // Separate model for vision tasks (can be same as OllamaModel)
EnableImageAnalysis bool // Enable AI-powered image analysis
MaxImageSizeBytes int64 // Maximum image size to download (bytes)
ImageTimeout time.Duration // Timeout for downloading individual images
LinkScoreThreshold float64 // Minimum score for link to be recommended (0.0-1.0)
StoragePath string // Base path for filesystem storage
MaxImages int // Maximum number of images to download per scrape (0 = unlimited)
}
Config contains scraper configuration
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns default scraper configuration
type Scraper ¶
type Scraper struct {
// contains filtered or unexported fields
}
Scraper handles web scraping operations
func New ¶
func New(config Config, db DB, storage StorageBackend) *Scraper
New creates a new Scraper instance db parameter can be nil if image deduplication is not needed storage parameter can be nil if storage is not needed
func (*Scraper) ExtractLinks ¶
ExtractLinks fetches a URL and returns links using Ollama with fallback to basic extraction
func (*Scraper) OllamaClient ¶
OllamaClient returns the Ollama client for external use
type StorageBackend ¶
type StorageBackend interface {
SaveImage(imageData []byte, slug, contentType string) (string, error)
SaveContent(content, slug string) (string, error)
ReadImage(relPath string) ([]byte, error)
ReadContent(relPath string) (string, error)
DeleteImage(relPath string) error
DeleteContent(relPath string) error
}
StorageBackend interface defines the storage operations needed by the scraper
Click to show internal directories.
Click to hide internal directories.