Link to home
Start Free TrialLog in
Avatar of dnotestine
dnotestine

asked on

How to turn off Internet Explor image requests

I'm using the Internet Explorer control in a VB 6 project. I have the Visible property set to false but according to my Network Proxy Server it is requesting all the images, etc. Is there a way so it will only request the HTML? Other HTTP controls I've used in the past allowed you to turn off image requests to speed things up.
Avatar of PaulHews
PaulHews
Flag of Canada image

You can get the contents of HTML pages without loading the webbrowser control at all.  It's the easiest way to ensure you are only downloading what you requested.

Return the Contents of a Web Page Using WinInet API
http://www.freevbcode.com/ShowCode.Asp?ID=1252
Avatar of dnotestine
dnotestine

ASKER

Thats great code but my project revolves around manipulating link objects in the DOM object. How could I get the html string into a DOM object?
>Thats great code but my project revolves around manipulating link objects in the DOM object. How could I get the html string into a DOM object?

What kind of manipulation?  With a string you could parse out all the links and probably do whatever you needed to do with them as well.  (I'll help with the code if I know what you're trying to do.)  Since there's no user interaction, I'm not seeing what would require the heavy weight instance of a web browser control.
That would be great :-)
I need to be able to loop through every link, having the ability to modify the Anchor Text and/or the href url.

For 0 to AllLinks

   Get Anchor Text
   Get Href
   Look at both of them and put them back depending on the results
   Put some Anchor Text back
   Put a Href back

Next

When you say "put them back" what do you mean?  Are you navigating to each of the links?  Are you showing the web browser at some point?
I'm looking at the links for matches, testing for relative links, adding a path if needed, etc. Then depending on this, I replace the old href.

For the Anchor text, I may change the wording and replace the old anchor text with it.
Okay, but what's the end goal?  Showing the page in the webbrowser?  
The end goal is saving the DOM (converting to a string first)) to an HTML file, then after all the pages are done, FTP to a web site. Then the pages would be looked at by visitors to the web site.

A simple application of the program would be to move a web sites pages to another web site. The program would change the relative links to absolute, Head tag, etc, to make this possible

During the program execution, the pages are never seen in the browser.
Here's a sample that shows how to parse out all the links from a page and determine if they are relative or absolute.  But let me know if I'm going in the right direction with this:

You need a reference to Microsoft VBScript Regular Expressions.  You also need the code from the link above in a module, with the OpenURL function set as Public.


Option Explicit

Private Sub Command1_Click()
    Dim strPage As String
   
    strPage = OpenURL("https://www.experts-exchange.com/questions/22718901/How-to-turn-off-Internet-Explor-image-requests.html")
   
    Dim regex As RegExp
    Set regex = New RegExp
    regex.Pattern = "<a\s+href=""(http://)*?(.*?)"".*?>\s*((\n|.)+?)\s*</a>"
    regex.Global = True
    regex.IgnoreCase = True
    Dim Matches As MatchCollection
    Set Matches = regex.Execute(strPage)
    Dim m As Match
    For Each m In Matches
        If m.SubMatches(0) = "http://" Then
            Debug.Print "Absolute URL:"
        Else
            Debug.Print "Relative URL:"
        End If
        Debug.Print "Link: " & m.SubMatches(1)
        Debug.Print "Link text: " & m.SubMatches(2)
    Next
   
End Sub
Very nice :-) At last, I meet someone who knows MS Regular Expressions.

How do I substitute the SubMatches(1) and SubMatches(2) if I need to.

If you would like I could ask another question so you could get more points as I think you've earned the ones for this question. Will you get notice of questions from me or how do I get notice to you?
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial