Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.IO;
- using Newtonsoft.Json;
- public class Program
- {
- public static void Main()
- {
- dynamic stuff = JsonConvert.DeserializeObject(Get("https://api.spacexdata.com/v3/launches?rocket_id=falcon9&launch_success=false"));
- foreach(string ship in stuff[0].ships) {
- dynamic stuff2 = JsonConvert.DeserializeObject(Get("https://api.spacexdata.com/v3/ships/" + ship));
- Console.WriteLine(stuff2.ship_type);
- }
- }
- public static string Get(string uri)
- {
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
- request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
- using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
- using(Stream stream = response.GetResponseStream())
- using(StreamReader reader = new StreamReader(stream))
- {
- return reader.ReadToEnd();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement