|
-
Jun 27th, 2007, 01:13 AM
#1
Thread Starter
Junior Member
Grabbing text/images from webpage using Vb/VB.net
Does anybody know what is the api use for grabbing contents from webpages in vb/vb.net?
can you gimme a small example.
-
Jun 27th, 2007, 03:33 AM
#2
Re: Grabbing text/images from webpage using Vb/VB.net
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.
-
Jun 27th, 2007, 07:16 AM
#3
Addicted Member
Re: Grabbing text/images from webpage using Vb/VB.net
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)
Last edited by xoggoth; Jun 27th, 2007 at 07:25 AM.
-
Jun 27th, 2007, 07:31 AM
#4
Addicted Member
Re: Grabbing text/images from webpage using Vb/VB.net
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.
-
Jun 27th, 2007, 09:22 AM
#5
Hyperactive Member
Re: Grabbing text/images from webpage using Vb/VB.net
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|