Skip to content

Commit

Permalink
Log failed remote scraper as Error
Browse files Browse the repository at this point in the history
  • Loading branch information
Wikidepia committed Jul 9, 2024
1 parent cca5079 commit 78362d6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions handlers/scraper/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,18 @@ func (i *InstaData) ScrapeData() error {

// Scrape from remote scraper if available
if len(RemoteScraperAddr) > 0 {
var err error
req.Header.SetMethod("GET")
req.Header.Set("Accept-Encoding", "gzip, deflate, br")
req.SetRequestURI(RemoteScraperAddr + "/scrape/" + i.PostID)
if err := client.DoTimeout(req, res, timeout); err == nil && res.StatusCode() == fasthttp.StatusOK {
if err = client.DoTimeout(req, res, timeout); err == nil && res.StatusCode() == fasthttp.StatusOK {
iDataGunzip, _ := res.BodyGunzip()
if err := binary.Unmarshal(iDataGunzip, i); err == nil {
if err = binary.Unmarshal(iDataGunzip, i); err == nil {
log.Info().Str("postID", i.PostID).Msg("Data parsed from remote scraper")
return nil
}
}
log.Warn().Str("postID", i.PostID).Msg("Failed to scrape data from remote scraper")
log.Error().Err(err).Str("postID", i.PostID).Msg("Failed to scrape data from remote scraper")
}

req.Reset()
Expand Down

0 comments on commit 78362d6

Please sign in to comment.