Re: Get String From Webpage
In a webbrowser control or you just want to download the string behind the scenes and get the data? What version of Visual Studio?
Re: Get String From Webpage
Quote:
Originally Posted by
kleinma
In a webbrowser control or you just want to download the string behind the scenes and get the data? What version of Visual Studio?
just behind the scenes, 2010 .net framework 2
Re: Get String From Webpage
you are using VS2010 but targetting .NET 2.0?
Re: Get String From Webpage
Quote:
Originally Posted by
kleinma
you are using VS2010 but targetting .NET 2.0?
yea im just using 2.0 since it has everything that i need for this
Re: Get String From Webpage
Your best bet then would be regular expressions. You could manually parse out the data however that would be a much more complex cumbersome approach.
If you were using a newer version of the framework, then sometimes you can make use of things like XML literals where you can load a webpage into an XML document (if the webpage is infact well formed) and query data directly from that. Even if its not well formed (ie no root element) you can usually grab part of the text and load it as an XML fragment and still query/parse it easily.
Or if you were using a browser control, you could make use of the DOM objects the .NET framework exposes to parse the data.
Since you are just using .NET 2.0 and want to do it behind the scenes, try doing a search on here for regex and maybe a few other keywords like webpage, because there have been quite a few examples of this on here.
Re: Get String From Webpage
what would be the regex expression be? I've been looking and can not figure out exactly what it would be
Re: Get String From Webpage
ok here is my code
vb Code:
Dim objRegEx As System.Text.RegularExpressions.Regex
Dim objMatch As System.Text.RegularExpressions.Match
Dim arrLinks As New System.Collections.ArrayList()
' Create regular expression
objRegEx = New System.Text.RegularExpressions.Regex( _
"(?<=<a rel='lightbox' href=).*(?=>Image Only</a></td>)", _
System.Text.RegularExpressions.RegexOptions.IgnoreCase Or _
System.Text.RegularExpressions.RegexOptions.Compiled)
' Match expression to HTML
objMatch = objRegEx.Match(HTML)
' Loop through matches and add <1> to ArrayList
While objMatch.Success
Dim strMatch As String
strMatch = objMatch.Groups(1).ToString
ListBox1.Items.Add(strMatch)
objMatch = objMatch.NextMatch()
End While
but it is just adding blank lines to the listbox and not the strings it found
http://imgur.com/i4qqy.png