Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

URL call

Posted on 2003-02-27
14
Medium Priority
?
257 Views
Last Modified: 2010-05-01
I want to write a program which asks for a URL, then reads the received page, and saves it on my local disk.

Thanks in advance.
0
Comment
Question by:felix07
  • 5
  • 4
  • 2
  • +3
14 Comments
 
LVL 1

Accepted Solution

by:
magglass1 earned 150 total points
ID: 8035601
Create an Inet object then use

myHTML = Inet1.OpenURL("www.something.com")

to load the source into string myHTML.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8035652
Add an Internet transfer control

sub SaveHTML()
dim i as integer

i=freefile
open "c:myfile.htm" for output as #i
    print #i,inet1.openurl("http://www.mysite.com/indextml",icString)
close#i
end sub
0
 
LVL 14

Expert Comment

by:aelatik
ID: 8035687
If you don't want to use a control, you can use this with Richie's solution.....

Private Sub Form_Load()
GetHTMLCode ("http://www.google.com")
End Sub

Public Function GetHTMLCode(URL As String)
    Dim IE
    Set IE = CreateObject("InternetExplorer.Application")
        IE.Navigate URL
        While IE.Busy
            DoEvents
        Wend
            GetHTMLCode = IE.Document.body.innerHTML
    MsgBox GetHTMLCode
End Function
0
Technology Partners: 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!

 
LVL 1

Expert Comment

by:magglass1
ID: 8035694
Or if you want to modify the html first:

Add an Internet transfer control

sub SaveHTML()
dim i as integer

i=freefile
myHTML = Inet1.OpenURL("www.something.com")
'make modifications to myHTML
open "c:myfile.htm" for output as #i
   print #i,myHTML,icString)
close#i
end sub

That should be correct...
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8035839
nah, nah...that's not fair!!, at least change the name of sub or variable or, better, add "\" that it is missing...
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8035854
GetHTMLCode = IE.Document.body.innerHTML
 to

GetHTMLCode = IE.Document.documentelement.innerHTML

.Body return the html that is beteween <BODY></BODY> tags,
.Documentelement returns ALL, from <HTML> to </HTML>
Cheers
0
 
LVL 5

Expert Comment

by:Rhaedes
ID: 8041114
This code should do the whole thing for you.
First add a refernce to Microsoft Internet Controls (in SHDOCVW.DLL) and add these declarations to a form:


Dim IE As SHDocVw.InternetExplorer
Dim myWebPage As String


Then put a commandbutton (Command1) on the form, change its caption to 'Save a Webpage' and add the following code:


Private Sub Command1_Click()

myWebPage = InputBox("Type in the URL of the Webpage you wish to save", "Save a webpage", "http://www.google.com")
If myWebPage = "" Then Exit Sub 'User cancelled

Command1.Enabled = False 'Stop the user from trying to do more than 1 at a time
Command1.Caption = "Working..."

Set IE = New SHDocVw.InternetExplorer
IE.Navigate2 myWebPage
'IE.Visible=True 'Use this is you want to see the webpage

While IE.ReadyState <> READYSTATE_COMPLETE 'Wait until the browser is done
DoEvents
Wend

IE.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_PROMPTUSER 'Show save dialogue
Command1.Enabled = True
Command1.Caption = "Save a webpage"
End Sub


Hope this helps,
Kindest regards,
Rhaedes
0
 
LVL 5

Expert Comment

by:Rhaedes
ID: 8041130
...I meant to add that the advantage of doing it this way is that it takes advantage of the 'Save As' option in Explorer, so you get all the images and other related files, not just the HTML of the document.
Rhaedes
0
 
LVL 1

Expert Comment

by:magglass1
ID: 8041148
I am currently working on a program to do the equivlant or better of the 'Save As' option in Explorer.  I have asked a few questions at http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20532326.html
0
 

Author Comment

by:felix07
ID: 8063157
Thanks a lot for your answers.

Unfortunately, I am facing a new problem : a login and password is required to access to this URL.

How can I give the login and the password (in my Visual Basic program) to be able to access to this URL.

Thanks in advance,

Regards,

Felix.
0
 
LVL 1

Expert Comment

by:magglass1
ID: 8063174
Check out http://www.httrack.com/index.php.  There program supports using a login name and password on websites.
0
 
LVL 1

Expert Comment

by:magglass1
ID: 8063177
Should be http://www.httrack.com/index.php without the period at end, lol.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8064107
take a look at www.angelfire.com/realm/vb-shared/index.html under "IE DOM ..." topic.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8983735
Hi felix07,
It appears that you have forgotten to close this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Richie_Simonetti's comment(s) as an answer.
    *** but set the UserName and Password properties, then set the URL property

felix07, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept THIS comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

564 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