|
发表于 2014-11-20 16:06:13
|
显示全部楼层
正好可以回答你的问题
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web;
namespace webnet
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
public WebBrowser wb1;
private void Form2_Load(object sender, EventArgs e)
{
}
private void wb1load()
{
wb1 = new WebBrowser();
// wb1.Navigate("http://www.tianya.cn/"); //将这句话用占位符表示就可以了.将TXT1.txt里面的文本IP地址放进去
wb1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(counts); //委托事件
}
private void counts(object sender, WebBrowserDocumentCompletedEventArgs e)
{
try
{
label1.Text = "";
wb1.Document.Cookie.Remove(0, wb1.Document.Cookie.Length);
string s2 = wb1.Document.GetElementsByTagName("em")[0].InnerText;
string text= wb1.Document.Body.InnerText;
richTextBox1.Text = text;
}
catch (Exception ex)
{
label1.Text = "";
wb1.Dispose();
// MessageBox.Show("请关闭连接,重新打开!错误" + ex.Message);
}
finally
{
}
}
private void timer1_Tick_1(object sender, EventArgs e)
{
// wb1load();
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = "";
label2.Text = "";
}
private void button2_Click_1(object sender, EventArgs e)
{
wb1load();
}
}
}
|
|