?
Solved

URL call

Posted on 2003-02-27
14
Medium Priority
?
253 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
[X]
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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

765 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