所以我做了一个机器人,里面有一个查看器,可以访问文本框中的特定网址。现在我用 webbrowser1.navigate 函数做到了。
我听说我需要创建一个 httpwebrequest 函数而不是使用 webbrowser1 函数。
我应该使用此代码而不是 webbrowser1.navigate :这是我正在使用的代码:
公开课形式1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
WebBrowser1.Navigate(txtUrl.Text, "", Nothing, "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5" & vbCrLf & "Accept-Language: en-us" & vbCrLf)
lblCount.Text += 1
End Sub
结束类
块引用
我希望将它作为 webrequest 而不是浏览器,所以我应该在下面使用它吗?
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://google.it/");
WebProxy a=new WebProxy(); a.Address=new Uri("http://97.107.137.97:8080");
request.Proxy = a;
var response = (HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
并想将 URL 放在文本字段中?有谁知道我该怎么做?
先进的Thnx :)