diff options
| author | Philipp Tanlak <philipp.tanlak@gmail.com> | 2023-09-18 21:22:57 +0200 |
|---|---|---|
| committer | Philipp Tanlak <philipp.tanlak@gmail.com> | 2023-09-18 21:22:57 +0200 |
| commit | 49bde10c0b4d1c296960fbe94e30672da42df0e5 (patch) | |
| tree | ef866172a0f6d27b973e4bdf8f891004a956e93f /fetch.go | |
| parent | c0ef0e7b99382164964be5404e76c759229c1268 (diff) | |
set default user-agent to flyscrape/0.1
Diffstat (limited to 'fetch.go')
| -rw-r--r-- | fetch.go | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -13,6 +13,8 @@ import ( "github.com/cornelk/hashmap" ) +const userAgent = "flyscrape/0.1" + func ProxiedFetch(proxyURL string) FetchFunc { pu, err := url.Parse(proxyURL) if err != nil { @@ -63,7 +65,14 @@ func CachedFetch(fetch FetchFunc) FetchFunc { func Fetch() FetchFunc { return func(url string) (string, error) { - resp, err := http.Get(url) + req, err := http.NewRequest(http.MethodGet, url, nil) + if err != nil { + return "", err + } + + req.Header.Set("User-Agent", userAgent) + + resp, err := http.DefaultClient.Do(req) if err != nil { return "", err } |