Runtime Error

F

falderals

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(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.TextBox1.Multiline = True
Me.TextBox1.ScrollBars = ScrollBars.Both
'above only for showing the sample
Dim Doc As mshtml.IHTMLDocument2
Doc = New mshtml.HTMLDocumentClass
Dim wbReq As Net.HttpWebRequest = _
DirectCast(Net.WebRequest.Create("http://
start.csail.mit.edu/"), _
Net.HttpWebRequest)
Dim wbResp As Net.HttpWebResponse = _
DirectCast(wbReq.GetResponse(), Net.HttpWebResponse)
Dim wbHCol As Net.WebHeaderCollection = wbResp.Headers
Dim myStream As IO.Stream = wbResp.GetResponseStream()
Dim myreader As New IO.StreamReader(myStream)
Doc.write(myreader.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.StringBuilder
For i As Integer = 0 To Doc.all.length - 1
Dim hElm As mshtml.IHTMLElement = _
DirectCast(Doc.all.item(i), mshtml.IHTMLElement)
Select Case hElm.tagName.ToLower
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
 
F

falderals

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(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.TextBox1.Multiline = True
Me.TextBox1.ScrollBars = ScrollBars.Both
'above only for showing the sample
Dim Doc As mshtml.IHTMLDocument2
Doc = New mshtml.HTMLDocumentClass
Dim wbReq As Net.HttpWebRequest = _
DirectCast(Net.WebRequest.Create("http://
start.csail.mit.edu/"), _
Net.HttpWebRequest)
Dim wbResp As Net.HttpWebResponse = _
DirectCast(wbReq.GetResponse(), Net.HttpWebResponse)
Dim wbHCol As Net.WebHeaderCollection = wbResp.Headers
Dim myStream As IO.Stream = wbResp.GetResponseStream()
Dim myreader As New IO.StreamReader(myStream)
Doc.write(myreader.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.StringBuilder
For i As Integer = 0 To Doc.all.length - 1
Dim hElm As mshtml.IHTMLElement = _
DirectCast(Doc.all.item(i), mshtml.IHTMLElement)
Select Case hElm.tagName.ToLower
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._trackPageview();
</script>
</BODY>
 
C

Cor Ligthert[MVP]

Falderals,

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

Cor
 
F

falderals

Falderals,

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

Cor

The error is generated from this Java script on the page I believe:

var pageTracker = _gat._getTracker("UA-3387059-1");
pageTracker._initData();
pageTracker._trackPageview();
</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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top