WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing
Go Back  Xtreme Visual Basic Talk > > > WebBrowser Saving file as local and viewing


Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2006, 12:08 PM
cryo_burned cryo_burned is offline
Freshman
 
Join Date: May 2006
Posts: 25
Default WebBrowser Saving file as local and viewing


I have a page I'm trying to download then save as a local file, chop some code from it, then view it. I have my site and for advertising they put a script that when you click on the page a pop-up opens. So I was hoping to save the file local, trim that script away then view it without pop-ups. First though, I don't know how to save my HTML as a local file. How is this done?
Reply With Quote
  #2  
Old 06-22-2006, 01:11 PM
MikeJ's Avatar
MikeJWebBrowser Saving file as local and viewing MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,747
Default

Check out the URLDownloadToFile API.
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #3  
Old 06-22-2006, 02:27 PM
cryo_burned cryo_burned is offline
Freshman
 
Join Date: May 2006
Posts: 25
Default

thats cool but I can't get this to work:
Code:
Private Sub Form_Load() Dim localfile As String localfile = App.Path & "/" & "currentmessages.html" Label1.Caption = Form1.Caption DownloadFile "www.immortals-inc.com/pabox/pabox.php", localfile WebBrowser1.Navigate (localfile) End Sub
I did compile it to make sure the EXE was in the right spot.. help,please? The webbrowser does successfully navigate, but the page source isn't downloading...
Reply With Quote
  #4  
Old 06-22-2006, 02:45 PM
MikeJ's Avatar
MikeJWebBrowser Saving file as local and viewing MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,747
Default

Can you add a Debug.Print on localfile to see what it's resolving to? If that resolves okay, then add the "http://" to the DownloadFile call, I believe that is also a prerequisite.

With this advice, I am assuming that you are using the DownloadFile function that is included as an example on AllAPI...
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #5  
Old 06-22-2006, 03:43 PM
cryo_burned cryo_burned is offline
Freshman
 
Join Date: May 2006
Posts: 25
Default

I dont know how to debug.print... but i'll try that http:// req. and yes, i am using the allapi example.

But app.path should be the folder the exe is in

Last edited by cryo_burned; 06-22-2006 at 03:57 PM.
Reply With Quote
  #6  
Old 06-22-2006, 03:45 PM
cryo_burned cryo_burned is offline
Freshman
 
Join Date: May 2006
Posts: 25
Default

good call! It was the http:// thing... now can i modify the function and make the downloaded file a string the subtract some characters from it, or do i need to reopen it?
Reply With Quote
  #7  
Old 06-22-2006, 03:47 PM
MikeJ's Avatar
MikeJWebBrowser Saving file as local and viewing MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,747
Default

For your reference, Debug.Print just displays the value of the variable(s) at the time it's called.

The reason why I ask is in case the App.Path is a root directory (C:\, D:\, etc.) it will attach an extra backslash, and it would not recognize a path of C:\\currentmessages.html.
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #8  
Old 06-22-2006, 03:52 PM
MikeJ's Avatar
MikeJWebBrowser Saving file as local and viewing MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,747
Default

OK, now that you have the file downloaded, you can open it up using methods that can be found in GavinO's File I/O Tutorial. Chris00 has posted a good example of parsing things out of a webpage, see that article here: http://www.xtremevbtalk.com/showthread.php?t=64878.
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #9  
Old 06-22-2006, 07:22 PM
cryo_burned cryo_burned is offline
Freshman
 
Join Date: May 2006
Posts: 25
Default

i have a problem. I can trim the string and everything. But, I'm putting my string into a webbrowser not a textfield. How can I achieve this?
Reply With Quote
  #10  
Old 06-22-2006, 10:32 PM
MikeJ's Avatar
MikeJWebBrowser Saving file as local and viewing MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,747
Default

WebBrowser.Document.documentElement.innerHTML returns the string of the HTML. I'm pretty sure it can be used to set it as well.
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #11  
Old 06-28-2006, 03:35 PM
cryo_burned cryo_burned is offline
Freshman
 
Join Date: May 2006
Posts: 25
Default

I dont know how to use that function let alone reverse engineer it..
Reply With Quote
  #12  
Old 06-28-2006, 05:15 PM
MikeJ's Avatar
MikeJWebBrowser Saving file as local and viewing MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,747
Default

It's not a function, it's a property.
Code:
'Shows the complete page source MsgBox WebBrowser.Document.documentElement.outerHTML

Save the string to the local machine, and navigate to it.
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #13  
Old 06-28-2006, 05:38 PM
Birchy's Avatar
Birchy Birchy is offline
Junior Contributor
 
Join Date: Aug 2005
Location: Hereford, UK
Posts: 346
Default

I was gonna suggest WinHTTP and a GET or POST request but i think you'd be better off understanding the WebBrowser first.
Reply With Quote
  #14  
Old 06-28-2006, 08:17 PM
calder calder is offline
Contributor
 
Join Date: Nov 2005
Posts: 483
Default

skip the webbrowser for getting the text =/

Add the Microsoft Internet transfer control then use the inet to grab the source. The replacing of the script is gonna be a pain but... This is the easiest and likely quickest way to get the source code.

Code:
Text1.text = inet1.openurl ("http://yourwebpage.com")
__________________
I have learned more about VB from this forum in 3 months than I learned alone in 1 year. Share your knowledge and learn from others ;)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing
 
WebBrowser Saving file as local and viewing
WebBrowser Saving file as local and viewing
 
-->