0

I've used WebClient class in C# and tried the following code to get a text file from a PHP script generating a Json script. I need to read this in C#. The following code is used:

var client = new WebClient();
String text = client.DownloadString("http://healthmonitor.epizy.com/getHistory.php?start=20181113100504&ending=20181113103453");
textBox5.Text = text;

The output was this:

<html><body><script type="text/javascript" src="/aes.js" ></script><script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("7a3810cb30970e29869e0e75c85f0a7e");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://healthmonitor.epizy.com/getHistory.php?start=20181114200744&ending=20181114200744&i=1";</script><noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript></body></html>

The expecting result is a Json in text from as you can simply check this: http://healthmonitor.epizy.com/getHistory.php?start=20181113100504&ending=20181113103453

Much appreciate if someone can help me to sort this out.

Thanking You in advance!

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Althaf
  • 143
  • 2
  • 11

1 Answers1

2

You are getting this error, because the website is using JavaScript. But your client (= your c# program), does not support JavaScript like a browser does.

It says so at the end of the HTML response:

This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support

Erik Kalkoken
  • 30,467
  • 8
  • 79
  • 114
  • Thank you @Erik Kalkoken for the response. Is there anyways I can get the text from http://healthmonitor.epizy.com/getHistory.php?start=20181113100504&ending=20181113103453 – Althaf Nov 14 '18 at 14:47
  • 1
    You could use selenium with a headless chrome browser to browse to the site, from there you should be able to extract the DOM as a string. – Matt Luccas Phaure Minet Nov 14 '18 at 14:51
  • I think you need to add a JavaScript engine to your app that is able to interpret the JS code that is embedded in the PHP script. This answer seams to provide some good enigines: https://stackoverflow.com/questions/172753/embedding-javascript-engine-into-net – Erik Kalkoken Nov 14 '18 at 15:01