Results 1 to 9 of 9

Thread: [2005] Catching ad url's in browser

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    London, England
    Posts
    142

    [2005] Catching ad url's in browser

    I've been building an advanced browser, and it's been fun, here's the latest problem i'm suffering from,

    When i navigate to a page that uses ad.google.blah, the original url is resolved, then its resolving the ad url as well, is there any way to stop this, maybe by checking the link against the hosts file?

    if you need to see code, i'll post it


    Redmo
    The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp


    Please rate the posts that have helped. Makes us feel all warm and fuzzy

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Catching ad url's in browser

    you mean you are trying to prevent embedded content like an ad on a page from displaying?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    London, England
    Posts
    142

    Re: [2005] Catching ad url's in browser

    No, if i wanted to do that, i could remove the content by comparing my url string to the contents of the hosts file, but this is what's happening

    url= http://sourceforge.net
    resovled url = http://ad.uk.doubleclick.net/adi/N1120.blah blah

    is there a way i can stop this from happening?

    Redmo
    The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp


    Please rate the posts that have helped. Makes us feel all warm and fuzzy

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Catching ad url's in browser

    i guess I do need you to post your code. I dont know what you mean by url versus resolved url

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    London, England
    Posts
    142

    Re: [2005] Catching ad url's in browser

    Ok, here's what i'm using when go is clicked, there's no checks in there to see what kind of url it is, it just does what its supposed to do

    VB Code:
    1. Private Sub tsbGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbGo.Click
    2.  
    3.         'make sure string isn't empty
    4.         If tscbAddress.Text = Nothing Then
    5.             MsgBox("Please enter an Address", MsgBoxStyle.MsgBoxHelp, "Warning")
    6.         Else
    7.             'catch about:home
    8.             If CBool(String.Compare(tscbAddress.Text.Substring(0, 6), "about:home")) = True Then
    9.             Else
    10.                 'catch about:blank
    11.                 If CBool(String.Compare(tscbAddress.Text.Substring(0, 6), "about:blank")) = True Then
    12.  
    13.                 Else
    14.                    
    15.                     'finds out if string contains the required http://
    16.                     If CBool(String.Compare(tscbAddress.Text.Substring(0, 7), "http://")) = True Then
    17.                         'if it does, then no need to add it
    18.                         If tscbAddress.Text.Contains("http://") Then
    19.                         Else
    20.                             'if it doesn't then we add it here
    21.                             tscbAddress.Text = "http://" & tscbAddress.Text.ToString()
    22.                         End If
    23.                     End If
    24.                 End If
    25.             End If
    26.         End If
    27.  
    28.         Try
    29.             tmrBrowser.Enabled = True ' Start the animation
    30.             wbPKMN.Navigate(tscbAddress.Text) ' Get the URL from the control, and send the WebBrowser to fetch and display it
    31.         Catch ex As UriFormatException
    32.             nwWriteLogMsg(ex.Message, ".\nwpps2k6err.log", ex.StackTrace, ex.TargetSite.ToString, ex.Source, ex.HelpLink)
    33.             With frmException
    34.                 .lblTitle.Text = "UriFormatException"
    35.                 .txtDesc.Text = ex.Message & " Error Number: " & Err.Number
    36.                 .lblSource.Text = ex.Source
    37.                 .lblTargetMethod.Text = ex.TargetSite.ToString
    38.                 .ctbSTrace.Text = ex.StackTrace
    39.                 .ShowDialog(Me)
    40.             End With
    41.         End Try
    42.        
    43.  
    44.     End Sub

    The code for the keypress event is exactly the same, no point in using different code to do the same thing

    Its like the page url is sorted, then its treating the ad's as if the go event has been fired again, therefore runnin this again, and putting the new url in the combobox.

    Redmo
    The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp


    Please rate the posts that have helped. Makes us feel all warm and fuzzy

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Catching ad url's in browser

    I still don't see the problem. The code in this routine should only fire when the button is clicked.

    Do you have other code in the webbrowsers navigate complete or document complete events?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    London, England
    Posts
    142

    Re: [2005] Catching ad url's in browser

    This is the code for my WebBrowser_completed

    VB Code:
    1. Private Sub wbPKMN_Navigated(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles wbPKMN.Navigated
    2.  
    3.         tscbAddress.Text = e.Url.AbsoluteUri ' add completed url to tscbaddress text.
    4.  
    5.         'Run test to see if the url is already in the collection
    6.         If tscbAddress.Items.Contains(e.Url.AbsoluteUri) Then
    7.             'if so, then we don't need to add it again
    8.             Exit Sub
    9.         Else
    10.             'add the url to the collection
    11.             tscbAddress.Items.Add(e.Url.AbsoluteUri)
    12.         End If
    13.  
    14.     End Sub

    The only other code that's ran on a regular basis is the selectedIndexChanged

    VB Code:
    1. Private Sub tscbAddress_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tscbAddress.SelectedIndexChanged
    2.         'Get selected item by casting from object
    3.         Dim SelectedUrl As String = CType(tscbAddress.SelectedItem, String)
    4.        
    5.        
    6.        
    7.         Try
    8.             'If string is empty then exit try
    9.             If SelectedUrl Is Nothing Then
    10.                 Exit Sub
    11.             End If
    12.            
    13.             'if string is already in the collection then exit sub
    14.             If tscbAddress.Items.Contains(SelectedUrl) = True Then
    15.                 wbPKMN.Navigate(SelectedUrl)
    16.                
    17.             End If
    18.         Catch ex As UriFormatException
    19.             nwWriteLogMsg(ex.Message, ".\nwpps2k6err.log", ex.StackTrace, ex.TargetSite.ToString, ex.Source, ex.HelpLink)
    20.             With frmException
    21.                 .lblTitle.Text = "UriFormatException"
    22.                 .txtDesc.Text = ex.Message & " Error Number: " & Err.Number
    23.                 .lblSource.Text = ex.Source
    24.                 .lblTargetMethod.Text = ex.TargetSite.ToString
    25.                 .ctbSTrace.Text = ex.StackTrace
    26.                 .ShowDialog(Me)
    27.             End With
    28.         End Try
    29.     End Sub

    This is baffling, but i'm sure i'll come up with an answer eventually

    Redmo
    The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp


    Please rate the posts that have helped. Makes us feel all warm and fuzzy

  8. #8
    Addicted Member Daystar's Avatar
    Join Date
    Dec 2006
    Location
    Pahrump, NV
    Posts
    132

    Re: [2005] Catching ad url's in browser

    I think your problem is not a coding problem. When a web-browser goes to a page that links offsite. It must resolve those links as well. Or in otherwords if the site links to an ad-site for content. That is being resolved after the initial page has been resolved. So what seems to happening is your catching the last resolved URL. Which comes from with in the web-page it self. Just a thought.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Location
    London, England
    Posts
    142

    Re: [2005] Catching ad url's in browser

    Yes, i agree daystar, if i try to catch the offending urls in a trap, i could be tryin to grab 100's of ad urls. I'll figure out a way around it though, give me time

    Redmo
    The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp


    Please rate the posts that have helped. Makes us feel all warm and fuzzy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width