mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
Refactoring. Move system plugins to seperate DLLs.
This commit is contained in:
34
Plugins/Wox.Plugin.WebSearch/SuggestionSources/Google.cs
Normal file
34
Plugins/Wox.Plugin.WebSearch/SuggestionSources/Google.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Wox.Infrastructure.Http;
|
||||
|
||||
namespace Wox.Plugin.WebSearch.SuggestionSources
|
||||
{
|
||||
public class Google : AbstractSuggestionSource
|
||||
{
|
||||
public override List<string> GetSuggestions(string query)
|
||||
{
|
||||
var result = HttpRequest.Get("https://www.google.com/complete/search?output=chrome&q=" + Uri.EscapeUriString(query));
|
||||
if (string.IsNullOrEmpty(result)) return new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
JContainer json = JsonConvert.DeserializeObject(result) as JContainer;
|
||||
if (json != null)
|
||||
{
|
||||
var results = json[1] as JContainer;
|
||||
if (results != null)
|
||||
{
|
||||
return results.OfType<JValue>().Select(o => o.Value).OfType<string>().ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user