random user agents

This commit is contained in:
partisan 2024-06-02 12:05:25 +02:00
parent 4e8ca3192f
commit 8e5f8c8a10
8 changed files with 418 additions and 12 deletions

View file

@ -58,7 +58,22 @@ func (tg *TorrentGalaxy) Search(query string, category string) ([]TorrentResult,
}
searchURL := fmt.Sprintf("https://%s/torrents.php?search=%s%s#results", TORRENTGALAXY_DOMAIN, url.QueryEscape(query), categoryCode)
resp, err := http.Get(searchURL)
// User Agent generation
userAgent, err := GetUserAgent("files-torrentgalaxy")
if err != nil {
fmt.Println("Error:", err)
return nil, err
}
req, err := http.NewRequest("GET", searchURL, nil)
if err != nil {
return nil, err
}
req.Header.Set("User-Agent", userAgent)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("error making request to TorrentGalaxy: %w", err)
}