Created
September 18, 2015 07:43
-
-
Save wayne-o/0265cec2614e8a66757d to your computer and use it in GitHub Desktop.
using google
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
private const string Xpath = "//*[@id=\"cwos\"]"; | |
static void Main(string[] args) | |
{ | |
var val = string.Empty; | |
var num1 = Convert.ToInt32(args[0]); | |
var num2 = Convert.ToInt32(args[1]); | |
var task = Task.Run(async () => | |
{ | |
using (var client = new HttpClient()) | |
{ | |
var url = "http://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=" + num1 + "*" + num2; | |
var responseString = await client.GetStringAsync(url); | |
var doc = new HtmlDocument(); | |
doc.LoadHtml(responseString); | |
var node = doc.DocumentNode.SelectNodes(Xpath)[0]; | |
val = node.Attributes["value"].Value; | |
} | |
}); | |
Task.WaitAll(new[] { task }); | |
Console.WriteLine(val); | |
Console.ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment