vb.net httpwebrequest使用google链接获取html

vb.net httpwebrequest使用google链接获取html,vb.net,httpwebrequest,Vb.net,Httpwebrequest,上面是我从网页获取html的代码。如果输入这样的内容,我会遇到问题 它给了我 Imports System.Net Imports System.IO Public Class Form1 Public Function GetHTML(ByVal url As Uri) As String Dim HTML As String Dim Request As HttpWebRequest Dim Response As HttpWebR

上面是我从网页获取html的代码。如果输入这样的内容,我会遇到问题

它给了我

Imports System.Net
Imports System.IO

Public Class Form1
    Public Function GetHTML(ByVal url As Uri) As String
        Dim HTML As String

        Dim Request As HttpWebRequest
        Dim Response As HttpWebResponse
        Dim Reader As StreamReader

        Try
            Request = HttpWebRequest.Create(url)
            Response = Request.GetResponse
            Reader = New StreamReader(Response.GetResponseStream())

            HTML = Reader.ReadToEnd
        Catch ex As Exception
            HTML = Nothing
        End Try

        Return HTML
    End Function

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim url As Uri = New Uri(TextBox1.Text)

        TextBox2.Text = GetHTML(url)
    End Sub
End Class
window.googleJavaScriptRedirect=1
var f={};
f、 导航到=功能(b、a、g){
if(b!=a&&b.google)
{
如果(b.google.r)
{
b、 google.r=0;
b、 location.href=g;
a、 位置。替换(“关于:空白”);
}
}
其他的
{
a、 位置.更换(g);
}
};
f、 导航到(window.parent,window,“http://www.vbforums.com/showthread.php?p\x3d3434187”);
而不是


如何让我的代码执行重定向并获取html?

从元标记中删除url,然后发出新请求。对于scraping,我推荐使用HtmlAgilityPack,您可以在下载或使用NuGet安装它。

从meta标记中删除url,然后发出新请求。对于scraping,我推荐使用HtmlAgilityPack,您可以在下载或使用NuGet安装它

   <script>window.googleJavaScriptRedirect=1</script>
    <script>
    var f={};
    f.navigateTo=function(b,a,g){
      if(b!=a&&b.google)
      {
        if(b.google.r)
         {
           b.google.r=0;
           b.location.href=g;
           a.location.replace("about:blank");
         }
      }
      else
      {
        a.location.replace(g);
      }
    };

    f.navigateTo(window.parent,window,"http://www.vbforums.com/showthread.php?p\x3d3434187");

    </script>
    <noscript>
    <META http-equiv="refresh" content="0;URL='http://www.vbforums.com/showthread.php?p=3434187'">
    </noscript>