Login  
Search All Forums
Dart Home | PowerTCP Web Enterprise for ActiveX | Custom Development Reply | PowerTCP Web Enterprise for ActiveX Topics | Forums   
AuthorForum: PowerTCP Web Enterprise for ActiveX
Topic: Images
User353

Posts: 3
Member Since: 10/22/01
posted December 22, 2001 5:51 AM

Hello,
 
I am using Dart web control to fetch a web page.
the page contains some images , so i want to fetch imags and save them on local machine.
 
i have written the following Vb code for getting images :-
 
''''''' VB CODE
 
Private Sub GetImages(strUrl As String)

Dim WebAsp1 As New WebASP
Dim WebPage1 As New WebPage
 
Dim blnResult As Boolean
 
WebAsp1.Request.KeepAlive = True
WebAsp1.Timeout = 30000
 
' set request url
WebAsp1.Request.Url = strUrl
WebAsp1.Get
 
' set webpage source to html source from response
WebPage1.Source = WebAsp1.Response.Body.ReadString
 
' iterate through WebResources, be sure to set WebPage.UrlHost first
WebPage1.UrlHost = WebAsp1.Request.Url
 
For i = 1 To WebPage1.Resources.Count
 
 If WebPage1.Resources.Item(i).UrlType = resImg Then
 ' this WebResource is an image, so write to file
 
  blnResult = WebPage1.Resources(i).Get("C:\Images\", False, 3000)
  If blnResult = True Then
    MsgBox WebPage1.Resources(i).UrlName & " successfully written to file"
  End If
 End If
Next
End Sub
 

Private Sub Command1_Click()
 Call GetImages("http://localhost/chess.htm")
End Sub

'''''''''''''''End Of CODE
 
 
Can any one help me to get images from a given web page ?
 
 
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted December 24, 2001 10:02 AM


Hi,
Your code looks and seems to work fine.
Just be sure to include the name of the file in your WebPage.Resource.Get:
blnResult = WebPage1.Resources(i).Get("c:\Images\file.gif", False, 3000)
-ken

K M Drake
Dart Tech Support
User353

Posts: 3
Member Since: 10/22/01
posted December 29, 2001 12:02 AM

hello Drake,

i have changed the code as per your suggestion but still not getting the images. the new code is like this :--

 blnResult = WebPage1.Resources(i).Get("C:\Images\" + WebPage1.Resources.Item(i).UrlName, False, 3000)

Where WebPage1.Resources.Item(i).UrlName is the name of the image.

have you done any other change to get the images?

Prasanna.
but i am getting value of blnResult = false



K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted December 31, 2001 11:16 AM


Hi Prasanna,
Below is the simple test project I used. When executed, five gifs are placed in an Images subdirectory on my machine. Is it different for you?
Thanks,
-ken

Private Sub Command1_Click()
  GetImages ("http://support.dart.com")
End Sub

Private Sub GetImages(strUrl As String)
  Dim WebPage1 As New WebPage
  Dim blnResult As Boolean
  Dim i As Integer
  
  WebASP1.Request.Url = strUrl
  WebASP1.Get

  WebPage1.Source = WebASP1.Response.Body.ReadString
  WebPage1.UrlHost = WebASP1.Request.Url
 
  For i = 1 To WebPage1.Resources.Count
    If WebPage1.Resources.Item(i).UrlType = resImg Then
      blnResult = WebPage1.Resources(i).Get(App.Path & "\Images\" & WebPage1.Resources(i).UrlName, False, 3000)
      If blnResult = True Then MsgBox WebPage1.Resources(i).UrlName & " successfully written to file"
    End If
  Next
End Sub

K M Drake
Dart Tech Support
Reply | PowerTCP Web Enterprise for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX