Zoltan Kerenyi

Zoltan Kerenyi

  • NA
  • 72
  • 13.4k

parsing HTTP response

May 13 2020 12:16 AM
Hi,
 
I'd like to parse out the OFF from the http response that look like this in a browser:
 
in the Browser's Inspector:
 
In WireShark:
 
 
And in code debugger:
 
The problem is that the delimiter is a paragraph sign.
 
I really need to know the current relay state, this is the latest code, I've been experimenting with:
 
  1. public string GetRelayState(byte relay)  
  2.         {  
  3.             string api = $"http://{Ip}/api2.cgi?p={Password}";  
  4.             var request = (HttpWebRequest)WebRequest.Create(api);  
  5.             request.AllowAutoRedirect = false;  
  6.             HttpWebResponse response = (HttpWebResponse)request.GetResponse();  
  7.             Stream stream = response.GetResponseStream();  
  8.             StreamReader s = new StreamReader(stream);  
  9.   
  10.   
  11.             return s.ReadToEnd().Split('\u00a7')[2];  
  12.       
  13.   
  14.         } 
 
 Could you please help me out?
 

Answers (1)