Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using System.IO;
  8. using System.Diagnostics;
  9. using System.Net;
  10. using System.Text.RegularExpressions;
  11.  
  12. namespace ConsoleApp7
  13. {
  14. class Program
  15. {
  16. private static string requestData;
  17.  
  18.  
  19. static void Main(string[] args)
  20. {
  21. int x = 1;
  22. while(x <= 4)
  23. {
  24. HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("WEB ADDRESS GOES HERE ! ");
  25. webRequest.Method = "POST";
  26. using (StreamWriter streamWriter = new StreamWriter(webRequest.GetRequestStream(), Encoding.UTF8))
  27. {
  28. streamWriter.Write(requestData);
  29. }
  30.  
  31. string responseData = string.Empty;
  32. HttpWebResponse httpResponse = (HttpWebResponse)webRequest.GetResponse();
  33. using (StreamReader responseReader = new StreamReader(httpResponse.GetResponseStream()))
  34. {
  35. responseData = responseReader.ReadToEnd();
  36. }
  37.  
  38. string str = Convert.ToString(responseData);
  39.  
  40. int range = Convert.ToInt32(System.Text.RegularExpressions.Regex.Match(str, @"\d+").Value);
  41. Convert.ToString(range);
  42. Console.WriteLine(range);
  43. Console.Title = Convert.ToString(range) + " mi of range on our Tesla Model S";
  44. System.Threading.Thread.Sleep(
  45. (int)System.TimeSpan.FromSeconds(5).TotalMilliseconds);
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement