mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Adjust Bing Code a bit due to http change
This commit is contained in:
parent
3708489886
commit
191c6af38e
1 changed files with 9 additions and 9 deletions
|
|
@ -21,8 +21,8 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
try
|
||||
{
|
||||
const string api = "https://api.bing.com/qsonhs.aspx?q=";
|
||||
|
||||
using var resultStream = await Http.GetStreamAsync(api + Uri.EscapeDataString(query), token).ConfigureAwait(false);
|
||||
|
||||
await using var resultStream = await Http.GetStreamAsync(api + Uri.EscapeDataString(query), HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false);
|
||||
|
||||
using var json = (await JsonDocument.ParseAsync(resultStream, cancellationToken: token));
|
||||
var root = json.RootElement.GetProperty("AS");
|
||||
|
|
@ -31,16 +31,16 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
return new List<string>();
|
||||
|
||||
return root.GetProperty("Results")
|
||||
.EnumerateArray()
|
||||
.SelectMany(r => r.GetProperty("Suggests")
|
||||
.EnumerateArray()
|
||||
.Select(s => s.GetProperty("Txt").GetString()))
|
||||
.ToList();
|
||||
.EnumerateArray()
|
||||
.SelectMany(r => r.GetProperty("Suggests")
|
||||
.EnumerateArray()
|
||||
.Select(s => s.GetProperty("Txt").GetString()))
|
||||
.ToList();
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e) when (e is HttpRequestException or {InnerException: TimeoutException})
|
||||
catch (Exception e) when (e is HttpRequestException or { InnerException: TimeoutException })
|
||||
{
|
||||
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
|
||||
return null;
|
||||
|
|
@ -49,7 +49,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
|||
{
|
||||
Log.Exception("|Bing.Suggestions|can't parse suggestions", e);
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
|||
Loading…
Reference in a new issue