所以我制作了一个带有viewcounter的机器人,它可以访问文本框中的特定网址。 现在我用webbrowser1.navigate函数创建了它。
我听说我需要创建一个httpwebrequest函数而不是使用webbrowser1函数。
我应该使用此代码而不是webbrowser1.navigate: 这是我使用的代码:
Public Class Form1
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();
并想将网址放在文本字段中? 有谁知道我怎么做???
先进的Thnx:)