VB6 - Submit Web Form, Scan Response, Save Image to My Web Server

Posted on 2006-11-11
Last Modified: 2008-01-16
Yet again, a question that seems like it should have a simple answer, but I am stuck anyway.  

*** My PC is Windows XP Pro with all critical updates. ***

I want to use VB6 to:

1.  Submit a webform from my PC.  The form can be seen at:

2.  After submitting the form, scan the response from the remote webserver for the URL of an image I need (of Earth).  The URL for the image is hashed using an algorythm I don't have.   I have to read the URL out of the page source sent back by the web server.  The URL for the image is findable by searching for the <img> tag in the page source.  Example URL for image:

3.  Use the URL of the image to update the image file on my server (i.e., copy the image from the remote server to overwrite the image on my web server.)  

4.  This needs to be a background process, running every 5 minutes on my PC.  My PC has access to my web server, via FTP.

I have a web page that displays a picture of the Earth 

The problem is I want to update the picture based on the time it is being viewed (within 5 minutes of when the page is requested).  

To see what I mean, go to this page, then submit the web form at that page.  You will see a current picture of Earth, from space, with the clouds removed, showing day and night light.

I want to grab the picture off that page, then display it on my web page, so it will look something like this, depending on the date/time:

Complication:  the Earth pictures I want to use come from someone else's website.  The URLs of the pictures at that website vary with the date/time shown by the picture.  So, I need a way to capture the pictures, even though the URLs change.

I want to write a VB6 program that will, in effect, submit the web form every 5 minutes, then save an updated version the Earth picture onto my web server, so my web page can display it.  

I have written VB6 programs to do things along this line, but it's been a few years.  Additionally, I don't have access to the source code I did those years ago.

I need someone to tell me which objects I need to use in VB6 to get the picture update program working.   For instance, is there an object I can use to submit a web form, then scan the web page source coming back in response, without displaying the web page in a browser?

This PDF file lays out the path I am trying to follow, along with more detail on where the complications exist.

Any assistance in working through this problem will be appreciated immensely.  

I'll add points to the question (or open sub questions) to reward various people contributing, assuming that happens.  If someone can step me through this, I would think 200-300 points would be in order.  I am starting low on points, in case I need to open new questions to get this problem solved.  I have no problem adding points as warranted.

Thank  you in advance.
Question by:Danimal
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 16

Accepted Solution

JohnBPrice earned 85 total points
ID: 17931246
It's not too hard.  One way is to use the Inet control (Microsoft Internet Transfer Control), this should do it.  Obviously you want to change the parameters used to get the image as required.

    Dim PostData As String
    Dim result As String
    Dim i As Integer
    Dim j As Integer
    Dim imageURL As String
    Dim Image() As Byte
    'Get the page that contains the image link
    PostData = "imgsize=320&;opt=-l&;lat=22.125&;ns=North&;lon=99.625&;ew=West&;alt=148024950&;img=learth.evif"
    Inet1.Execute "" & PostData
    While Inet1.StillExecuting
    result = Inet1.GetChunk(10000)
    'find the image link
    i = InStr(1, result, "/cgi-bin/Earth?di=")
    j = InStr(i, result, """")
    imageURL = Mid(result, i, j - i)
    'Get the image itself
    Inet1.Execute "" & imageURL
    While Inet1.StillExecuting
    Image = Inet1.GetChunk(1000000, 1) ' in actuality it only gets the number of bytes in the image
    'save it to a file
    Open "C:\test\earth.jpg" For Binary Access Write As #1
    Put #1, , Image()
    Close #1

LVL 16

Expert Comment

ID: 17931289
Oh, to post it to your server, you would do something like this

    Inet1.url = "ftp://<yourFTPSite>"
    Inet1.UserName = "<yourusername>"
    Inet1.Password = "<yourpassword>"
    Inet1.Execute , "PUT C:\test\earth.jpg <YourFTPFolder>\earth.jpg "
    While Inet1.StillExecuting
    Inet1.Execute , "QUIT"

Author Comment

ID: 17931616

If I get stuck or have followon questions, I will let you know.  In the meantime, thank  you....

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question