read from sourcecode of website

pulsmartin

Member
Joined
Jun 3, 2009
Messages
6
Programming Experience
1-3
From my vb.net application I need to get certain information from a website. I want to read certain parts of the sourcecode of the website, how would I do this?
 
Depending on what you want to do with the source, WebBrowser control (to get a fully parsed DOM tree) or WebClient class (plain text).
VB.NET:
Dim web As New Net.WebClient
Dim source As String = web.DownloadString("url")
 
read sourcecode of website

Should source contain the whole text of the sourcecode? It doesn't seem to be working, it's an empty string.
 
read source code from website

I realized, that when I view the sourcecode from the website or from my webbrowser control there are no html tags, there is only text. Also, the type is php, I don't know if that makes a difference.
 
DownloadString will return the same text that any browser will get when navigating to the given url, it doesn't matter what technology serves the content. If you're talking about getting the source code for the server application that serves that content then that is not possible, only client side code (such as html, js, xml) and plain text is served when browsing webserver urls.
 
DownloadString will return the same text that any browser will get when navigating to the given url, it doesn't matter what technology serves the content. If you're talking about getting the source code for the server application that serves that content then that is not possible, only client side code (such as html, js, xml) and plain text is served when browsing webserver urls.

when I rightclick on the browser control, then do view source, I can see the text (which doesn't include html tags). Can I not get that text in code?
 
That should be the text you should get, unless it was dynamically served by a client script, ie something the regular browser would render, but this doesn't sound as the case here. Perhaps the server app serves different content to different user agents?
 
What does that mean? I did see that I can open the website with IE but not with Firefox, with Firefox it had to be saved.
So what I did now, was save the file and then read from it, I am not sure if that is a good way to go about it.
 
Back
Top