From be115e60dec063fe62a2d2b06eb010cecb2b51f3 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Tue, 10 May 2016 19:37:09 +0200 Subject: [PATCH] Tried to fix gelbooru search by specifying headers --- NadekoBot/Classes/SearchHelper.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/NadekoBot/Classes/SearchHelper.cs b/NadekoBot/Classes/SearchHelper.cs index 60bf22ba..049772cd 100644 --- a/NadekoBot/Classes/SearchHelper.cs +++ b/NadekoBot/Classes/SearchHelper.cs @@ -254,9 +254,13 @@ namespace NadekoBot.Classes public static async Task GetGelbooruImageLink(string tag) { + var headers = new Dictionary() { + {"User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"}, + {"Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" }, + }; var url = - $"http://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=100&tags={tag.Replace(" ", "_")}"; - var webpage = await GetResponseStringAsync(url).ConfigureAwait(false); + $"http://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=100&tags={tag.Replace(" ", "_")}"; + var webpage = await GetResponseStringAsync(url, headers).ConfigureAwait(false); var matches = Regex.Matches(webpage, "file_url=\"(?.*?)\""); if (matches.Count == 0) return null;