get html

I want to get the source code of a web page. I have tried
Dim bFile() As Byte         ' Retrieving a binary file.

bFile() = Inet1.OpenURL _
    ("http://www.webpage.htm", _
    icByteArray)

' Write file to disk.
Open "C:\web\main.htm" For Binary Access Write As #1
Put #1, , bFile()
Close #1

I have also tried opening the webpage in a richtextbox and saving as a file.
The problem is I want the file that I save to be exactly the same, line for line as the document Im downloading. Doing it both of these ways the file I get back is a mass of text on the first few lines. Adter I get the file I want to be able to go through it line by line.
I hope this is clear enough
beebopAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mcriderCommented:
Try this instead:

Dim lPage As String

lPage = Inet1.OpenURL("http://www.webpage.com", icString)
Do While Inet1.StillExecuting = True
    DoEvents
Loop
Open "C:\web\main.htm" For Output Access Write As #1
Put #1, , lPage
Close #1


Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
beebopAuthor Commented:
It is producing an error 'bad file number'
Dim lPage As String
fnum5 = FreeFile()
lPage = Inet1.OpenURL("http://www.webpage.com", icString)
Do While Inet1.StillExecuting = True
    DoEvents
Loop
Open myfile For Output Access Write As #fnum5
Put #fnum5, , lPage
Close #fnum5

works with print instead of put, but still the same problem, All the text on the first few lines.
0
mcriderCommented:
Sorry, your're right, that should have been print, not put... I just copied your example and changed the OpenURL line.

Try this:

Dim iVal As Long
Dim lPage As String

lPage = Inet1.OpenURL("http://www.webpage.com", icString)
Do While Inet1.StillExecuting = True
    DoEvents
Loop
Open "C:\web\main.htm" For Output Access Write As #1
Do
    iVal = InStr(1, lPage, Chr$(10))
    If iVal = 0 Then Exit Do
    Print #1, Left$(lPage, iVal - 1)
    lPage = Mid$(lPage, iVal + 1)
Loop
Print #1, lPage
Close #1


Cheers!

0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

beebopAuthor Commented:
thankyou mcrider, works perfectly
cheers
bee
0
mcriderCommented:
Thanks for the points! Glad I could help!


Cheers!
0
beebopAuthor Commented:
just one more bit of advice, if you know. Does the inet control have a limit on the size of file it will download, and if so can it be changed. I am trying to download a 75kb file and it cuts off half way through.
0
mcriderCommented:
There is no limit.  Check out these microsoft documents:

FIX: INET OpenURL Method Doesn't Download Complete Files
http://support.microsoft.com/support/kb/articles/Q171/8/28.asp?LNG=ENG&SA=MSDN 
 
INFO: Visual Basic 5.0 Fixes in Visual Studio 97 Service Pack 2
http://support.microsoft.com/support/kb/articles/Q171/5/54.asp?LNG=ENG&SA=MSDN 
 
Since this is extra information, if you're feeling generous, you can open a new question here with the title "FOR MCRIDER ONLY" and assign a couple of points to it... I will answer it.



Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.