SokomoKud SokomoKud - 1 year ago 118 Question

Get string from website

Before anything, sorry for my english, I'm still learning..

For example: I want to my app to read this site and return the value after "Present Version =" and save this to a variable.

I tried some codes from here, some I just didn't understand, others I cannot can make to work.

The last question I tried: Get text/string from html element but I didn't saw how to apply to this site.

Answer Source

You can achieve this by using a httpwebrequest and reading its response, then you've just got to do some string manipulation to isolate the version. Here's an example of how to use a httpwebrequest to call a web page and read its response. After that, I just split the response into lines and isolate the version from the first line. The part that actually pulls the version number out can be done a number of ways, but here's a quick example:

Dim req As HttpWebRequest = CType(WebRequest.Create(""), HttpWebRequest)
Dim sr As New StreamReader(CType(req.GetResponse(), HttpWebResponse).GetResponseStream())
Dim lines() As String = sr.ReadToEnd.Split(ControlChars.CrLf.ToCharArray(),
Dim version As String = lines(0).Substring(lines(0).IndexOf("=") + 1,
                                           lines(0).Length - lines(0).IndexOf("=") - 1).Trim
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download