feat: Add support for exclusionary CSS paths in config.go

This commit is contained in:
Arik Jones (aider)
2024-09-14 20:59:08 -05:00
parent ece9492b30
commit 53dcd6eb71
3 changed files with 13 additions and 10 deletions

View File

@@ -49,6 +49,7 @@ func runWeb(cmd *cobra.Command, args []string) error {
urlConfigs[i] = scraper.URLConfig{
URL: u.URL,
CSSLocator: u.CSSLocator,
ExcludeSelectors: u.ExcludeSelectors,
OutputAlias: u.OutputAlias,
}
}

View File

@@ -22,6 +22,7 @@ type ScrapeConfig struct {
type URLConfig struct {
URL string `yaml:"url"`
CSSLocator string `yaml:"css_locator"`
ExcludeSelectors []string `yaml:"exclude_selectors"`
OutputAlias string `yaml:"output_alias"`
}

View File

@@ -67,7 +67,7 @@ func scrapeURL(config URLConfig) (string, error) {
}
if config.CSSLocator != "" {
content, err = ExtractContentWithCSS(content, config.CSSLocator, nil)
content, err = ExtractContentWithCSS(content, config.CSSLocator, config.ExcludeSelectors)
if err != nil {
return "", err
}
@@ -99,6 +99,7 @@ func sanitizeFilename(name string) string {
type URLConfig struct {
URL string
CSSLocator string
ExcludeSelectors []string
OutputAlias string
}