 |
Sorin Olteanu's Linguae Thraco-Daco-Moesorum Site devoted to thracological philology
|
| View previous topic :: View next topic |
| Author |
Message |
Sorin Olteanu Guest
|
Posted: Sun Oct 01, 2006 7:41 am Post subject: How to save an image from a HTML file (Visual Basic)? |
|
|
I know how to download a HTML page into a Web browser (with Navigate and DocumentComplete). My problems are the followings:
-how could I download only the text of a page, with no images, if possible with no scripts, objects etc.
-if I downloaded a whole page, how can I save from code an image in the page (in other words, how can I execute from code the right-click menu command 'Save image as...'?
Thanks! |
|
| Back to top |
|
 |
Dragos Guest
|
Posted: Mon Oct 02, 2006 1:02 pm Post subject: |
|
|
| Quote: | | -how could I download only the text of a page, with no images, if possible with no scripts, objects etc. | I will think on it. You can do it nevertheless in a "raw mode". Open a HTTP socket on the server (you know the URL, the HTTP port is 80) and retrieve the page source via HTTP commands.
| Quote: | | -if I downloaded a whole page, how can I save from code an image in the page (in other words, how can I execute from code the right-click menu command 'Save image as...'? | I haven't worked extensively with Web browser control and I have to investigate the control to see if such features are available. However, you can parse the source of the page (you certainly can retrieve an XML document in a IHTMLDocument object), find the image, calculate its URL combining the URL of the page and the relative path read from image's source and download the image yourself.
In .NET 2.0 framework there's a method named DrawToBitmap available for all controls (allowing a rectangular area of a displayed control to be saved in a bitmap) but I know of no correspondences in VB 5.0/6.0. |
|
| Back to top |
|
 |
Dragos Guest
|
Posted: Mon Oct 02, 2006 7:27 pm Post subject: |
|
|
Sorin, I can make a .NET application/component for this job.
One question though: if there are several images linked in the HTML page, which one (how can the application identify it) should be downloaded? |
|
| Back to top |
|
 |
Nikola Guest
|
Posted: Sat Oct 07, 2006 10:17 am Post subject: Re: How to save an image from a HTML file (Visual Basic)? |
|
|
| Sorin Olteanu wrote: | how could I download only the text of a page, with no images, if possible with no scripts, objects etc.
|
You can use the program "Teleport Pro" and in it there is an option "download text only". It's working. |
|
| Back to top |
|
 |
Sorin Olteanu Guest
|
Posted: Mon Oct 09, 2006 6:21 pm Post subject: |
|
|
Excuse me, both of you, for my long delay.
Nikola, thanks for your idea, but I was thinking to do that from within a Visual Basic program.
Dragos, mai intâi îţi mulţumesc pentru ofertă, dar n-aş vrea să îţi răpesc timpul (cel puţin nu acum şi nu cu asta!!). Eu am lucrat cu controlul WebBrowser. N-am putut înţelege în detaliu acest nou 'bubbling' DOM sistem, dar, luând-o băbeşte, cu biblioteca MSDN [trebuie neapărat să revin la asta!], am înţeles că pot accesa orice colecţie de obiecte dintr-un WebBrowser.Document.
Cred că acum, scriindu-ţi, mi-am dat seama cum se poate face: obiectul HTMLDocument are, printre colecţii, una care se numeşte Images, compusă din obiecte IMG. Cred că un asemenea obiect (HTMLImg? sau asa ceva), are o proprietate Picture. Dacă e aşa, atunci o pot salva din VB cu comanda SavePicture (File$, Picture As stdPicture).
Revenind la MSDN: n-am reuşit să-mi procur de nicăieri MSDN-ul pentru VB6, astfel încât Help-ul de context (cel cu F1) nu-mi funcţionează. Când am nevoie, deschid manual Help=ul VB5-ului. Ştii cumva de unde l-aş putea procura?
Mai am să-ţi scriu câteva lucruri, dar mai bine pe PM. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|