Does anybody know what is the api use for grabbing contents from webpages in vb/vb.net?
can you gimme a small example.
Printable View
Does anybody know what is the api use for grabbing contents from webpages in vb/vb.net?
can you gimme a small example.
I only know that if you add a webBrowser control to your form, load a page and then run this (and other variations can get you other text) you can get all the main text:
vb Code:
Dim myText As String = Me.WebBrowser1.Document.Body.InnerText
You can look at getting the inner html for example and find the links to images and maybe get the images that way and download them but apart from that i don't know about images.
Not used this specific one but there are various methods associated with the document allowing access to and setting specific parts of it, including an images collection. From a quick look think you want the outer html property, this is string containing the src="imagename" bit that you want, eg:
<img alt="Close this page" src="images\butt_stop.gif" border=2 width=100%>
Parse string to get name from the src= bit and put it on a control using Image.FromFile.
To get 1st image say, bung a webbrowser on then summit like:
webbrowser1.Navigate(New System.Uri(FileName))
str = WebBrowser1.Document.Images(0).OuterHTML
....parse string for src name into imagename here
control.Image = System.Drawing.Image.FromFile(Imagename)
Or quick and dirty to get text without tags use clipboard
WebBrowser1.Document.ExecCommand("SelectAll", False, Nothing)
WebBrowser1.Document.ExecCommand("Copy", False, Nothing)
WebBrowser1.Document.ExecCommand("Unselect", False, Nothing)
Something or other to paste text into textbox here - not used it.
yeah, if you have a webbrowser control on your form. If not use the webclient class to post, get, and grab images from a page.