Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Newtonsoft.Json.Linq;;
- ...
- private void button1_Click(object sender, EventArgs e) {
- textBox1.AppendText("Searching 'Jarett Dunn'");
- textBox1.AppendText(Environment.NewLine);
- HttpWebRequest request = WebRequest.Create("https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Jarett%20Dunn") as HttpWebRequest;
- using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
- {
- StreamReader reader = new StreamReader(response.GetResponseStream());
- var json = reader.ReadLine();
- var objects = JObject.Parse(json)["responseData"]["results"];
- for (int i = 0; i <= 3; i++)
- {
- var title = objects[i]["titleNoFormatting"];
- var content = objects[i]["content"];
- textBox1.AppendText("Result #: " + i.ToString());
- textBox1.AppendText(Environment.NewLine);
- textBox1.AppendText(Environment.NewLine);
- textBox1.AppendText("Title: " + title.ToString());
- textBox1.AppendText(Environment.NewLine);
- textBox1.AppendText("Contents: " + content.ToString());
- textBox1.AppendText(Environment.NewLine);
- textBox1.AppendText(Environment.NewLine);
- textBox1.AppendText(Environment.NewLine);
- }
- }
- }
Add Comment
Please, Sign In to add comment