diff --git a/internal/jikan/relations.go b/internal/jikan/relations.go index 276df27..61fded9 100644 --- a/internal/jikan/relations.go +++ b/internal/jikan/relations.go @@ -2,6 +2,7 @@ package jikan import ( "context" + "errors" "fmt" "log" "strings" @@ -49,7 +50,11 @@ func (c *Client) getWatchOrder(ctx context.Context, id int) (watchorder.WatchOrd result, err := watchorder.FetchWatchOrder(requestCtx, c.httpClient, watchOrderURL) if err != nil { - log.Printf("relations: watch-order fetch failed for %d (%s): %v", id, watchOrderURL, err) + if errors.Is(err, watchorder.ErrWatchOrderMarkupNotFound) { + log.Printf("relations: watch-order markup missing for %d (%s): %v", id, watchOrderURL, err) + } else { + log.Printf("relations: watch-order fetch failed for %d (%s): %v", id, watchOrderURL, err) + } return watchorder.WatchOrderResult{}, err } diff --git a/internal/watchorder/watch_order.go b/internal/watchorder/watch_order.go index e41a830..731a759 100644 --- a/internal/watchorder/watch_order.go +++ b/internal/watchorder/watch_order.go @@ -12,7 +12,7 @@ import ( "github.com/PuerkitoBio/goquery" ) -const defaultUserAgent = "anime-relations-scraper/1.0 (+https://github.com/mkelvers/anime-relations)" +const defaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36" var idPattern = regexp.MustCompile(`/id/(\d+)`) @@ -64,6 +64,10 @@ func fetchDocument(ctx context.Context, httpClient *http.Client, url string) (*g } request.Header.Set("User-Agent", defaultUserAgent) + request.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8") + request.Header.Set("Accept-Language", "en-US,en;q=0.9") + request.Header.Set("Referer", "https://chiaki.site/") + request.Header.Set("Cache-Control", "no-cache") response, err := client.Do(request) if err != nil {