Grabbing the latest dist number via code

LetsRaceBwoi

Well-Known Member
So, for those wanting to make custom launchers, this is how you grab the latest dist number in C#. Be aware that this scrapes the javascript used on the frontpage (it's exactly what's in the "Servo Builds" box), but anyways here's the code:
Code:
            string url = "http://servo.freeso.org/externalStatus.html?js=1";
            WebRequest wrGETURL;
            wrGETURL = WebRequest.Create(url);
            Stream objStream;
            objStream = wrGETURL.GetResponse().GetResponseStream();
            StreamReader objReader = new StreamReader(objStream);
            string sLine = "";
            string fll;
            fll = objReader.ReadLine();
            sLine = fll.Remove(0, 855);
            sLine = sLine.Remove(sLine.IndexOf("</a>"));
            MessageBox.Show("The latest build is " + sLine);
If the servo builds box ever changes I'll update this with it. There were probably easier ways to do this, but I went and chose this one because of its simplicity in code form, and because I couldn't find where the javascript was pointing to in terms of requests to get the version number (i.e. a GET request to http://servo.freeso.org/version?js=1)
 
Code:
sLine = fll.Remove(0, 855);
I understand the reasons for not using an xml parser, but note that if we add more projects, change any of the project names or change the build bot title this will no longer work.
 
Back
Top