Aditya
Aditya

Reputation: 9

Grab text from webpage using vb

i want code that grab text from webpage

here is the html

<div><span>Version : </span> " 1.3"</div>

so i want 1.3 text in textbox1

Upvotes: 0

Views: 126

Answers (1)

jlee88my
jlee88my

Reputation: 3043

To manipulate HTML elements/documents easily, you need to install HTML Agility Pack. You can get it from NuGet at: https://www.nuget.org/packages/HtmlAgilityPack

After you have it, you can do a lot of magic with HTML documents/tags.

Dim voHAP As New HtmlAgilityPack.HtmlDocument
voHAP.LoadHtml("<div><span>Version : </span> "" 1.3""</div>")
Dim voDiv As HtmlAgilityPack.HtmlNode = voHAP.DocumentNode.Elements("div")(0)

voDiv.RemoveChild(voDiv.Element("span"))
Dim vsText As String = Replace(voDiv.InnerText, """", "").Trim

The vsText variable will contain your value of 1.3. The final Replace() function is to remove the unwanted " characters in the string.

Upvotes: 1

Related Questions