Solved

download html to computer for process

Posted on 2002-06-23
18
195 Views
Last Modified: 2010-05-02
I am a newbie of VB. I want to write a program that:

First, download some html pages from a certain site(which is generated by CGI) to a specified directory

Then, open the html file and do the processing.

Finally, save the list of processed data into a spread sheet file and delete the original html file

Can you tell me how to do the download step and the open file step?

thanks
0
Comment
Question by:leekf
  • 6
  • 6
  • 3
  • +1
18 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 7101480
Hi leekf,

Is that spreadsheet Excel?

if so there's an easier way

:O)Bruintje
0
 
LVL 8

Accepted Solution

by:
glass_cookie earned 200 total points
ID: 7101494
Hi!

Maybe you'd like to try using the INet control to download pages onto your PC:

Download...
http://www.vb-helper.com/HowTo/inetgetchunk.zip
Description: Use the Internet Transfer Control's Execute method and GetChunk to download a file (3K)

That's it!

glass cookie : )
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 7101497
Here's a last one:

Download...
http://www.planetsourcecode.com/vb/scripts/ShowZip.asp?lngWId=1&lngCodeId=21636&strZipAccessCode=ODE%5F216366631
Description: A Complete Multi Downloader (using multithreads)

That's it!

glass cookie : )
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 2

Author Comment

by:leekf
ID: 7101581
thanks... really cool

but after I downloaded a html file using the Multi Downloader, what is the code to open it so that I can edit it?
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7101600
still wondering is this in excel or not?
0
 
LVL 2

Author Comment

by:leekf
ID: 7101634
thanks... really cool

but after I downloaded a html file using the Multi Downloader, what is the code to open it so that I can edit it?
0
 
LVL 2

Author Comment

by:leekf
ID: 7101637
o... in fact, there is no need to be excel... even text file will be ok... thanks
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7102015
Ypu could open the resukting html file just like any other plain file:
dim strContents as string
Open "c:\somefile.htm" for input as 1
   strContents =input(lof(1),1)
close

' do what you want with strContents
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7102089
LOL, glued your keys together Richie ;)
0
 
LVL 2

Author Comment

by:leekf
ID: 7102512
... sorry.. i miss out something in my question...

i also want to know how to fetch all the URL and email address that contain in the html file

thanks
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 7102548
Hi!

You could use the instr() method to find the position in the text (after opening the file) where a "http://" exists.  From there, you cou;d just simply use the mid function to get the string.  In other words:

1. Use the instr function to determine where the "http" lies.
2. Use the instr method to find ".htm" or ".html" to determine the end of an address starting from the position of the 1st character of the "http://"

Sorry - no time to code them for you.  Let me know if you need me to code it for you : )  I'll probably do it tomorrow or some days later when I'm free : )

Use the mid function to retrieve the address from the difference in positions in the 1st and last characters.

That's it!

glass cookie : )
0
 
LVL 2

Author Comment

by:leekf
ID: 7102562
thanks... i have tried this method before...

Private Sub newprocess_Click()
Dim unprocess0, endvalue As String
Dim inresult1, inresult2, i As Integer
Dim result(100) As String

unprocess0 = txtResults.Text
For i = 1 To 100

inresult1 = InStr(unprocess0, "http://")
unprocess0 = Mid(unprocess0, inresult1 + 7, Len(unprocess0))
endvalue = "/"

inresult2 = InStr(unprocess0, endvalue)
result(i) = Left(unprocess0, inresult2 - 1)

List1.AddItem result(i)

Next i


End Sub


but there are some ugly URL in the list. i think the endvalue = "/" has problem. How to replace it?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7104292
I am not a good typist, i know ;)
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 7106470
Could you post a sample of the file you're opening so that I can have a clearer picture?  I'm not very sure how those urls are 'embedded' in the file.  Thanks : )
0
 
LVL 2

Author Comment

by:leekf
ID: 7106690
just like any html code, eg:

<a href="http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp" class="eeTopLink">Help Desk</a>
<a href="http://www.experts-exchange.com/jsp/cmtyHelpDeskKp.jsp" class="eeTopLink">KPro Help</a>

so... how to get the URL in this kind of file?
how to determine the end of an address?
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 7106904
Hi!

OK, simply look for a "http:// to start with and look for another " which indicates it's end through the instr() function.  In VB, they are:

i = instr(1,text1.text,"""http://")

and

instr(i+1,text1.text,"""")

That's it!

glass cookie : )
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7108594
You could use HTML object library and avoid using plain text. There are collections for almost everything.
If you need to enumerate hyperlinks for a given page, take a look at wwww.angelfire.com/realm/vb-shared/index.html under "IE DOM..." topic.
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 7120958
Thanks for the points  : )
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

832 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