[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to turn off Internet Explor image requests

Posted on 2007-07-24
11
Medium Priority
?
485 Views
Last Modified: 2013-12-26
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.
0
Comment
Question by:dnotestine
  • 6
  • 5
11 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 19562350
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
0
 

Author Comment

by:dnotestine
ID: 19566556
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?
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 19566787
>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.
0
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.

 

Author Comment

by:dnotestine
ID: 19568895
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

0
 
LVL 38

Expert Comment

by:PaulHews
ID: 19569049
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?
0
 

Author Comment

by:dnotestine
ID: 19569829
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.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 19571446
Okay, but what's the end goal?  Showing the page in the webbrowser?  
0
 

Author Comment

by:dnotestine
ID: 19575471
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.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 19576176
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("http://www.experts-exchange.com/Software/Internet_Email/Web_Browsers/Internet_Explorer/Q_22718901.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
0
 

Author Comment

by:dnotestine
ID: 19576973
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?
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 2000 total points
ID: 19577431
>Very nice :-) At last, I meet someone who knows MS Regular Expressions.
Someone who has a basic grasp of them anyway... I'm still teaching myself to use them efficiently.

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

There is the RegExp.Replace method, but in VB6, I usually find it lacks the granularity I need.  Here's a quick and dirty sample that walks through all the relative matches and replaces them depending on what they contain.  

Option Explicit

Private Sub Command1_Click()
    Dim strPage As String
    Dim strPath As String
    Dim strTemp As String
    Dim lngPos1 As Long, lngPos2 As Long
   
    strPage = OpenURL("http://www.experts-exchange.com/Software/Internet_Email/Web_Browsers/Internet_Explorer/Q_22718901.html")
    strPath = "Software/Internet_Email/Web_Browsers/Internet_Explorer/"
   
    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)
   
    lngPos1 = 1
    lngPos2 = 1
   
    Dim m As Match
    For Each m In Matches
        If Not m.SubMatches(0) = "http://" Then
           'Relative URL, convert to absolute:
           lngPos2 = m.FirstIndex + 1
           strTemp = strTemp & Mid$(strPage, lngPos1, lngPos2 - lngPos1)
           lngPos1 = lngPos2 + m.Length
           If Left$(m.SubMatches(1), 1) = "/" Then
                'relative to root
                strTemp = strTemp & "<a href=""http://www.mydomain.com" & m.SubMatches(1) & """>" & m.SubMatches(2) & "</a>"
           Else
                'relative to path
                strTemp = strTemp & "<a href=""http://www.mydomain.com/" & strPath & m.SubMatches(1) & """>" & m.SubMatches(2) & "</a>"
           End If
        Else
            Stop
        End If
        Debug.Print "Link: " & m.SubMatches(1)
        Debug.Print "Link text: " & m.SubMatches(2)
    Next
   
    Open "C:\temp\test.txt" For Output As #1
    Print #1, strTemp
    Close #1
    MsgBox "done"
   
   
End Sub



>f 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?

So that it's fair for all the experts, just ask your questions.  I will get notice so I'll pop in and see if I can help.  :-)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 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