Add User Agent to image download reqs (#1222)

This commit is contained in:
bnkai
2021-03-23 23:12:11 +02:00
committed by GitHub
parent 73a8bad1bc
commit 68d4a4fe42
4 changed files with 55 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package scraper
import (
"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
"strings"
@@ -113,6 +114,10 @@ func getImage(url string, globalConfig GlobalConfig) (*string, error) {
return nil, err
}
if resp.StatusCode >= 400 {
return nil, fmt.Errorf("http error %d", resp.StatusCode)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)