fix: resolve 5 bugs identified in code review

- Fix malformed YAML in config_test.go (incorrect indentation)
- Add validation for empty file_extensions in Config.Validate()
- Remove obsolete max_depth test case (field no longer exists)
- Remove unused global cfg variable in main.go
- Fix race condition in ScrapeSites by counting URLs before goroutines
- Remove unreachable JavaScript code in scroll script, add proper delay
- Standardize file extensions to not include leading dot
This commit is contained in:
Claude
2025-11-27 15:56:37 +00:00
parent 7569aff6ec
commit 09608cf073
5 changed files with 18 additions and 24 deletions

View File

@@ -74,6 +74,9 @@ func ScrapeSites(config Config) error {
var wg sync.WaitGroup
totalURLs := 0
for _, site := range config.Sites {
totalURLs += len(site.AllowedPaths)
}
for _, site := range config.Sites {
logger.Printf("Processing site: %s\n", site.BaseURL)
wg.Add(1)
@@ -81,7 +84,6 @@ func ScrapeSites(config Config) error {
defer wg.Done()
for _, path := range site.AllowedPaths {
fullURL := site.BaseURL + path
totalURLs++
logger.Printf("Queueing URL for scraping: %s\n", fullURL)
scrapeSingleURL(fullURL, site, results, limiter)
}
@@ -532,8 +534,6 @@ func scrollPage(page playwright.Page) error {
() => {
window.scrollTo(0, document.body.scrollHeight);
return document.body.scrollHeight;
// wait for 500 ms
new Promise(resolve => setTimeout(resolve, 500));
}
`
@@ -565,8 +565,8 @@ func scrollPage(page playwright.Page) error {
previousHeight = currentHeight
// Wait for a while before scrolling again
// Wait for content to load before scrolling again
time.Sleep(100 * time.Millisecond)
}
logger.Println("Scrolling back to top")