diff options
| author | Philipp Tanlak <philipp.tanlak@gmail.com> | 2024-02-17 21:47:43 +0100 |
|---|---|---|
| committer | Philipp Tanlak <philipp.tanlak@gmail.com> | 2024-02-17 21:47:43 +0100 |
| commit | 0b4c723d2c310310efba41f58ee3a626510bcd3a (patch) | |
| tree | 65017d8bdc18236557c466d0b51dc9983a891902 | |
| parent | f2d36972b238cb6bfe2548ec59508bbd83be0a05 (diff) | |
Mark non 2XX status code as errors
| -rw-r--r-- | scrape.go | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -9,6 +9,7 @@ import ( "log" "net/http" "net/http/cookiejar" + "strconv" "sync" "github.com/cornelk/hashmap" @@ -187,6 +188,10 @@ func (s *Scraper) process(url string, depth int) { response.StatusCode = resp.StatusCode response.Headers = resp.Header + if response.StatusCode < 200 || response.StatusCode >= 300 { + response.Error = strconv.Itoa(response.StatusCode) + " " + http.StatusText(response.StatusCode) + } + response.Body, err = io.ReadAll(resp.Body) if err != nil { response.Error = err |