fix(scraper): verify complete article evidence (#40)
This commit is contained in:
@ -3,6 +3,7 @@ package yahoofinance
|
||||
import (
|
||||
"context"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
@ -37,6 +38,7 @@ type rssFeed struct {
|
||||
|
||||
func (y *YahooFinance) Scrape(ctx context.Context, symbols []string) ([]scraper.Article, error) {
|
||||
var articles []scraper.Article
|
||||
reachable := false
|
||||
|
||||
for i, symbol := range symbols {
|
||||
if i > 0 {
|
||||
@ -50,8 +52,12 @@ func (y *YahooFinance) Scrape(ctx context.Context, symbols []string) ([]scraper.
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
reachable = true
|
||||
articles = append(articles, items...)
|
||||
}
|
||||
if len(symbols) > 0 && !reachable {
|
||||
return nil, errors.New("yahoofinance: source unavailable")
|
||||
}
|
||||
return articles, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user