vb webclient and javascript
-
I tried the VB board but maybe I'll have better luck here. :) I want to write a windows service application that reads a web page. That web page requires that the client can process javascript. Has anyone successfully implemented Javascript with System.Net.WebClient? I tried the code from the article "A simple .NET based WebClient with JavaScript support" but that code crashes with an inner JScriptException. Its acknowledged by the author and it looks like the trail ends there. According to microsoft the Microsoft.JScript.Vsa.VsaEngine used in that project is deprecated. What is the current working solution for processing webpages in code? This is what my code looks like. The web page at the URL I am calling uses javascript to set a cookie in order to prove that Javascript is running. It doesn't look like this code can do it. I can set cookies in advance but I can't seem to duplicate the javascipt setting a cookie. Help! Dim webClient As Net.WebClient = New System.Net.WebClient webClient.Credentials = System.Net.CredentialCache.DefaultCredentials webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705") webClient.Headers.Add(Net.HttpRequestHeader.Cookie, "aCookie:aCokievalue") Try Dim data As Stream = webClient.OpenRead(sURL) Dim reader As New StreamReader(data) Dim s As String = reader.ReadToEnd() 'response = webClient.DownloadData(sURL) 'Return Encoding.ASCII.GetString(response) Return s Catch ex As Exception Return "" End Try
-
I tried the VB board but maybe I'll have better luck here. :) I want to write a windows service application that reads a web page. That web page requires that the client can process javascript. Has anyone successfully implemented Javascript with System.Net.WebClient? I tried the code from the article "A simple .NET based WebClient with JavaScript support" but that code crashes with an inner JScriptException. Its acknowledged by the author and it looks like the trail ends there. According to microsoft the Microsoft.JScript.Vsa.VsaEngine used in that project is deprecated. What is the current working solution for processing webpages in code? This is what my code looks like. The web page at the URL I am calling uses javascript to set a cookie in order to prove that Javascript is running. It doesn't look like this code can do it. I can set cookies in advance but I can't seem to duplicate the javascipt setting a cookie. Help! Dim webClient As Net.WebClient = New System.Net.WebClient webClient.Credentials = System.Net.CredentialCache.DefaultCredentials webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705") webClient.Headers.Add(Net.HttpRequestHeader.Cookie, "aCookie:aCokievalue") Try Dim data As Stream = webClient.OpenRead(sURL) Dim reader As New StreamReader(data) Dim s As String = reader.ReadToEnd() 'response = webClient.DownloadData(sURL) 'Return Encoding.ASCII.GetString(response) Return s Catch ex As Exception Return "" End Try
Could you use the JScriptCodeProvider[^] class for this?
Deja View - the feeling that you've seen this post before.