Runtime Error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • falderals@yahoo.co.uk

    Runtime Error

    I get the runtime error "_gat is undefined" and a popup yes/no option
    to debug when I run the code below which is code to "screen scrape"
    the text off a web page without a browser. When I click "no debug" it
    continues and works ok. I suspect an error in the web page but being
    unable to fix it (and other web pages which have similar or worse
    problems) can I turn off the runtime error popup? The error does not
    occur in Microsoft IE though from Googling I found that you can turn
    off script debugging in IE which I cannot do here it seems.

    Public Class Form1
    Private Sub Form1_Load(ByVa l sender As System.Object, _
    ByVal e As System.EventArg s) Handles MyBase.Load
    Me.TextBox1.Mul tiline = True
    Me.TextBox1.Scr ollBars = ScrollBars.Both
    'above only for showing the sample
    Dim Doc As mshtml.IHTMLDoc ument2
    Doc = New mshtml.HTMLDocu mentClass
    Dim wbReq As Net.HttpWebRequ est = _
    DirectCast(Net. WebRequest.Crea te("http://
    start.csail.mit .edu/"), _
    Net.HttpWebRequ est)
    Dim wbResp As Net.HttpWebResp onse = _
    DirectCast(wbRe q.GetResponse() , Net.HttpWebResp onse)
    Dim wbHCol As Net.WebHeaderCo llection = wbResp.Headers
    Dim myStream As IO.Stream = wbResp.GetRespo nseStream()
    Dim myreader As New IO.StreamReader (myStream)
    Doc.write(myrea der.ReadToEnd() )
    Doc.close()
    wbResp.Close()

    'the part below is not completly done for all tags.
    'it can (will) be necessary to tailor that to your needs.

    Dim sb As New System.Text.Str ingBuilder
    For i As Integer = 0 To Doc.all.length - 1
    Dim hElm As mshtml.IHTMLEle ment = _
    DirectCast(Doc. all.item(i), mshtml.IHTMLEle ment)
    Select Case hElm.tagName.To Lower
    Case "body", "html", "head", "form"
    Case Else
    If hElm.innerText <"" Then
    sb.Append(hElm. innerText & vbCrLf)
    End If
    End Select
    Next
    TextBox1.Text = sb.ToString
    End Sub
    End Class
  • falderals@yahoo.co.uk

    #2
    Re: Runtime Error

    On Aug 10, 8:01 pm, falder...@yahoo .co.uk wrote:
    I get the runtime error "_gat is undefined" and a popup yes/no option
    to debug when I run the code below which is code to "screen scrape"
    the text off a web page without a browser. When I click "no debug" it
    continues and works ok. I suspect an error in the web page but being
    unable to fix it (and other web pages which have similar or worse
    problems) can I turn off the runtime error popup? The error does not
    occur in Microsoft IE though from Googling I found that you can turn
    off script debugging in IE which I cannot do here it seems.
    >
    Public Class Form1
    Private Sub Form1_Load(ByVa l sender As System.Object, _
    ByVal e As System.EventArg s) Handles MyBase.Load
    Me.TextBox1.Mul tiline = True
    Me.TextBox1.Scr ollBars = ScrollBars.Both
    'above only for showing the sample
    Dim Doc As mshtml.IHTMLDoc ument2
    Doc = New mshtml.HTMLDocu mentClass
    Dim wbReq As Net.HttpWebRequ est = _
    DirectCast(Net. WebRequest.Crea te("http://
    start.csail.mit .edu/"), _
    Net.HttpWebRequ est)
    Dim wbResp As Net.HttpWebResp onse = _
    DirectCast(wbRe q.GetResponse() , Net.HttpWebResp onse)
    Dim wbHCol As Net.WebHeaderCo llection = wbResp.Headers
    Dim myStream As IO.Stream = wbResp.GetRespo nseStream()
    Dim myreader As New IO.StreamReader (myStream)
    Doc.write(myrea der.ReadToEnd() )
    Doc.close()
    wbResp.Close()
    >
    'the part below is not completly done for all tags.
    'it can (will) be necessary to tailor that to your needs.
    >
    Dim sb As New System.Text.Str ingBuilder
    For i As Integer = 0 To Doc.all.length - 1
    Dim hElm As mshtml.IHTMLEle ment = _
    DirectCast(Doc. all.item(i), mshtml.IHTMLEle ment)
    Select Case hElm.tagName.To Lower
    Case "body", "html", "head", "form"
    Case Else
    If hElm.innerText <"" Then
    sb.Append(hElm. innerText & vbCrLf)
    End If
    End Select
    Next
    TextBox1.Text = sb.ToString
    End Sub
    End Class
    I forgot to add that when I do enter the debugger it points to script
    on the web page (out of my control)

    pageTracker._tr ackPageview();
    </script>
    </BODY>


    Comment

    • Cor Ligthert[MVP]

      #3
      Re: Runtime Error

      Falderals,

      Did you try this with Google.Com or Microsoft.Com or more regular like that
      (with full url including HTTP:\\)?

      Cor

      <falderals@yaho o.co.ukschreef in bericht
      news:9a1f5879-1ded-4e55-b423-f4a7fe0c97c9@y1 9g2000prn.googl egroups.com...
      >I get the runtime error "_gat is undefined" and a popup yes/no option
      to debug when I run the code below which is code to "screen scrape"
      the text off a web page without a browser. When I click "no debug" it
      continues and works ok. I suspect an error in the web page but being
      unable to fix it (and other web pages which have similar or worse
      problems) can I turn off the runtime error popup? The error does not
      occur in Microsoft IE though from Googling I found that you can turn
      off script debugging in IE which I cannot do here it seems.
      >
      Public Class Form1
      Private Sub Form1_Load(ByVa l sender As System.Object, _
      ByVal e As System.EventArg s) Handles MyBase.Load
      Me.TextBox1.Mul tiline = True
      Me.TextBox1.Scr ollBars = ScrollBars.Both
      'above only for showing the sample
      Dim Doc As mshtml.IHTMLDoc ument2
      Doc = New mshtml.HTMLDocu mentClass
      Dim wbReq As Net.HttpWebRequ est = _
      DirectCast(Net. WebRequest.Crea te("http://
      start.csail.mit .edu/"), _
      Net.HttpWebRequ est)
      Dim wbResp As Net.HttpWebResp onse = _
      DirectCast(wbRe q.GetResponse() , Net.HttpWebResp onse)
      Dim wbHCol As Net.WebHeaderCo llection = wbResp.Headers
      Dim myStream As IO.Stream = wbResp.GetRespo nseStream()
      Dim myreader As New IO.StreamReader (myStream)
      Doc.write(myrea der.ReadToEnd() )
      Doc.close()
      wbResp.Close()
      >
      'the part below is not completly done for all tags.
      'it can (will) be necessary to tailor that to your needs.
      >
      Dim sb As New System.Text.Str ingBuilder
      For i As Integer = 0 To Doc.all.length - 1
      Dim hElm As mshtml.IHTMLEle ment = _
      DirectCast(Doc. all.item(i), mshtml.IHTMLEle ment)
      Select Case hElm.tagName.To Lower
      Case "body", "html", "head", "form"
      Case Else
      If hElm.innerText <"" Then
      sb.Append(hElm. innerText & vbCrLf)
      End If
      End Select
      Next
      TextBox1.Text = sb.ToString
      End Sub
      End Class

      Comment

      • falderals@yahoo.co.uk

        #4
        Re: Runtime Error

        On Aug 10, 9:59 pm, "Cor Ligthert[MVP]" <notmyfirstn... @planet.nl>
        wrote:
        Falderals,
        >
        Did you try this with Google.Com or Microsoft.Com or more regular like that
        (with full url including HTTP:\\)?
        >
        Cor
        >
        <falder...@yaho o.co.ukschreef in berichtnews:9a1 f5879-1ded-4e55-b423-f4a7fe0c97c9@y1 9g2000prn.googl egroups.com...
        >
        I get the runtime error "_gat is undefined" and a popup yes/no option
        to debug when I run the code below which is code to "screen scrape"
        the text off a web page without a browser. When I click "no debug" it
        continues and works ok. I suspect an error in the web page but being
        unable to fix it (and other web pages which have similar or worse
        problems) can I turn off the runtime error popup? The error does not
        occur in Microsoft IE though from Googling I found that you can turn
        off script debugging in IE which I cannot do here it seems.
        >
        Public Class Form1
        Private Sub Form1_Load(ByVa l sender As System.Object, _
        ByVal e As System.EventArg s) Handles MyBase.Load
        Me.TextBox1.Mul tiline = True
        Me.TextBox1.Scr ollBars = ScrollBars.Both
        'above only for showing the sample
        Dim Doc As mshtml.IHTMLDoc ument2
        Doc = New mshtml.HTMLDocu mentClass
        Dim wbReq As Net.HttpWebRequ est = _
        DirectCast(Net. WebRequest.Crea te("http://
        start.csail.mit .edu/"), _
        Net.HttpWebRequ est)
        Dim wbResp As Net.HttpWebResp onse = _
        DirectCast(wbRe q.GetResponse() , Net.HttpWebResp onse)
        Dim wbHCol As Net.WebHeaderCo llection = wbResp.Headers
        Dim myStream As IO.Stream = wbResp.GetRespo nseStream()
        Dim myreader As New IO.StreamReader (myStream)
        Doc.write(myrea der.ReadToEnd() )
        Doc.close()
        wbResp.Close()
        >
        'the part below is not completly done for all tags.
        'it can (will) be necessary to tailor that to your needs.
        >
        Dim sb As New System.Text.Str ingBuilder
        For i As Integer = 0 To Doc.all.length - 1
        Dim hElm As mshtml.IHTMLEle ment = _
        DirectCast(Doc. all.item(i), mshtml.IHTMLEle ment)
        Select Case hElm.tagName.To Lower
        Case "body", "html", "head", "form"
        Case Else
        If hElm.innerText <"" Then
        sb.Append(hElm. innerText & vbCrLf)
        End If
        End Select
        Next
        TextBox1.Text = sb.ToString
        End Sub
        End Class
        The error is generated from this Java script on the page I believe:

        var pageTracker = _gat._getTracke r("UA-3387059-1");
        pageTracker._in itData();
        pageTracker._tr ackPageview();
        </script>

        which I thing maybe what Google recommend for people to track the
        number of users of a page.
        For other web pages I get even more problems...all kinds of runtime
        errors but they all go away if I select "no" for the debugging option.

        Is it possible to turn off the debugging option in VS?

        Comment

        Working...