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
|
|
@ -22,7 +22,7 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
||||||
{
|
{
|
||||||
const string api = "https://api.bing.com/qsonhs.aspx?q=";
|
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));
|
using var json = (await JsonDocument.ParseAsync(resultStream, cancellationToken: token));
|
||||||
var root = json.RootElement.GetProperty("AS");
|
var root = json.RootElement.GetProperty("AS");
|
||||||
|
|
@ -31,16 +31,16 @@ namespace Flow.Launcher.Plugin.WebSearch.SuggestionSources
|
||||||
return new List<string>();
|
return new List<string>();
|
||||||
|
|
||||||
return root.GetProperty("Results")
|
return root.GetProperty("Results")
|
||||||
.EnumerateArray()
|
.EnumerateArray()
|
||||||
.SelectMany(r => r.GetProperty("Suggests")
|
.SelectMany(r => r.GetProperty("Suggests")
|
||||||
.EnumerateArray()
|
.EnumerateArray()
|
||||||
.Select(s => s.GetProperty("Txt").GetString()))
|
.Select(s => s.GetProperty("Txt").GetString()))
|
||||||
.ToList();
|
.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);
|
Log.Exception("|Baidu.Suggestions|Can't get suggestion from baidu", e);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue