Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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

Posted on 2006-11-11
Medium Priority
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 340 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 "http://www.fourmilab.ch/cgi-bin/Earth?" & 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 "http://www.fourmilab.ch/" & 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

730 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