Skip to content

Commit

Permalink
perf: Add UA
Browse files Browse the repository at this point in the history
  • Loading branch information
Clov614 committed Jul 22, 2024
1 parent b28ba98 commit 9260fa4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rikkabot/utils/imgutil/imgutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ func fetchFromURL(url string) ([]byte, error) {
// 跳过 TLS 验证
tr := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
client := &http.Client{Transport: tr}
resp, err := client.Get(url)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return nil, fmt.Errorf("fetchFromURL: creating request: %w", err)
}
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36")

resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("fetchFromURL: http.Get(%q): %w", url, err)
}
Expand Down

0 comments on commit 9260fa4

Please sign in to comment.