Program.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using System;
  2. using System.Text;
  3. using System.Net.Http;
  4. using System.Net.Http.Headers;
  5. using System.Threading.Tasks;
  6. using Newtonsoft.Json;
  7. namespace ConsoleApp1
  8. {
  9. /*public class OrdinaryUrl
  10. {
  11. public string? type { get; set; }
  12. public string? url { get; set; }
  13. public string? suggested_link_text { get; set; }
  14. public OrdinaryUrl(string? type, string? url, string? suggested_link_text)
  15. {
  16. this.type = type;
  17. this.url = url;
  18. this.suggested_link_text = suggested_link_text;
  19. }
  20. }*/
  21. /*
  22. public class InformationCriminals
  23. {
  24. [JsonProperty("@id")] public string? Newid { get; set; }
  25. [JsonProperty("title")] public string? Title { get; set; }
  26. [JsonProperty("field_offices")] public string? Office { get; set; }
  27. [JsonProperty("details")] public string? Detail { get; set; }
  28. [JsonProperty("sex")] public string? Pol { get; set; }
  29. [JsonProperty("nationality")] public string? National { get; set; }
  30. [JsonProperty("age_max")] public int? Age { get; set; }
  31. [JsonProperty("height_max")] public int? Height { get; set; }
  32. [JsonProperty("race_raw")] public string? Race { get; set; }
  33. [JsonProperty("hair_raw")] public string? Hair { get; set; }
  34. [JsonProperty("languages")] public string? Language { get; set; }
  35. [JsonProperty("files")] public string? Urlpdf { get; set; }
  36. public InformationCriminals(string? underNewid, string? underTitle, string? underOffice, string?
  37. underDetails, string? underPol, string? underNational, int? underAge, int? underHeight,
  38. string? underRace,
  39. string? underHair, string? underLanguage, string? underPdf)
  40. {
  41. this.Newid = underNewid;
  42. this.Title = underTitle;
  43. this.Office = underOffice;
  44. this.Detail = underDetails;
  45. this.Pol = underPol;
  46. this.National = underNational;
  47. this.Age = underAge;
  48. this.Height = underHeight;
  49. this.Race = underRace;
  50. this.Hair = underHair;
  51. this.Language = underLanguage;
  52. this.Urlpdf = underPdf;
  53. }
  54. }*/
  55. class Contributor
  56. {
  57. public string items { get; set; }
  58. public override string ToString()
  59. {
  60. return $"{items} ";
  61. }
  62. }
  63. class Program
  64. {
  65. private static async Task Main()
  66. {
  67. using var client = new HttpClient();
  68. client.BaseAddress = new Uri("https://api.fbi.gov/wanted/v1/list");
  69. client.DefaultRequestHeaders.Accept.Add(
  70. new MediaTypeWithQualityHeaderValue("application/json"));
  71. var url = "https://api.fbi.gov/wanted/v1/list";
  72. HttpResponseMessage response = await client.GetAsync(url);
  73. response.EnsureSuccessStatusCode();
  74. var resp = await response.Content.ReadAsStringAsync();
  75. List<Contributor> contributors =
  76. JsonConvert.DeserializeObject<List<Contributor>>(resp);
  77. contributors.ForEach(Console.WriteLine);
  78. }
  79. }
  80. }
  81. /*class WantedPersons
  82. {
  83. public string title { get; set; }
  84. public char dates_of_birth_used { get; set; }
  85. public string nationality { get; set; }
  86. public string race_raw { get; set; }
  87. public string race { get; set; }
  88. public string hair_raw { get; set; }
  89. public string place_of_birth { get; set; }
  90. public string person_classification { get; set; }
  91. public string description { get; set; }
  92. public int height_max { get; set; }
  93. public int height_min { get; set; }
  94. public override string ToString()
  95. {
  96. return $"{title}: {dates_of_birth_used}: {nationality} nationality: {race_raw}:" +
  97. $" {race}: {hair_raw}: {place_of_birth}: {person_classification}: {description}:" +
  98. $"{height_max}: {height_min}";
  99. }
  100. }
  101. class Program
  102. {
  103. static async Task Main(string[] args)
  104. {
  105. using var client = new HttpClient();
  106. client.BaseAddress = new Uri("https://www.fbi.gov/wanted");
  107. client.DefaultRequestHeaders.Add("MostWanted Persons", "");
  108. client.DefaultRequestHeaders.Accept.Add(
  109. new MediaTypeWithQualityHeaderValue("application/json"));
  110. var url = "repos/symfony/symfony/persons";
  111. HttpResponseMessage response = await client.GetAsync(url);
  112. response.EnsureSuccessStatusCode();
  113. var resp = await response.Content.ReadAsStringAsync();
  114. List<WantedPersons> persons = JsonConvert.DeserializeObject<List<WantedPersons>>(resp);
  115. persons.ForEach(Console.WriteLine);
  116. }*/