看着那位牛人``做出来鸟```不由自主滴山寨鸟一个``````` http://user.qzone.qq.com/281011131/blog/1273847814?ptlang=2052&ADUIN=85390217&ADSESSION=1273891929&ADTAG=CLIENT.QQ.2719_FriendTip_QzoneFolder.0 ```(- -!)我有想学delphi的冲动! 额,还是先贴代码额`` 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.Net; using System.IO; using System.Text.RegularExpressions; using System.Collections; namespace 自动发帖 { public partial class Form1 : Form { string skinpath = Application.StartupPath + "/" + "cheng.ssk"; public Form1() { InitializeComponent(); this.skinEngine1.Active = true; this.skinEngine1.SkinFile = skinpath; } bool isExit1 = false; bool isExit2 = false; bool isExit3 = false; bool isExit4 = false; string[] url = {"http://172.16.200.17/post.asp?action=new&boardid=6","http://172.16.200.17/post.asp?action=new&boardid=10", "http://172.16.200.17/post.asp?action=new&boardid=25","http://172.16.200.17/post.asp?action=new&boardid=21", "http://172.16.200.17/post.asp?action=new&boardid=32"};//板块链接 int newID = 0; int newsCount = 0; string path = Application.StartupPath + "/" + "config.dat"; string newTitle; string newUrl; string[] news=new string[1000]; private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)//网页信息处理 { if (!isExit1) { try { HtmlElement ClickBtn = null; //HtmlElement ClickBtn2 = null; HtmlDocument doc = webBrowser1.Document; for (int i = 0; i < doc.All.Count; i++) { if (doc.All[i].TagName.ToString().Equals("INPUT")) { switch (doc.All[i].Name) { case "username": doc.All[i].InnerText = txtuser.Text; break; case "password": doc.All[i].InnerText = txtpsw.Text; break; case "submit": ClickBtn = doc.All[i]; //提交按钮 break; } } } ClickBtn.InvokeMember("Click"); //执行按扭操作 isExit1 = true; } catch { } } } private void btnlogin_Click(object sender, EventArgs e)//登录 { if (btnlogin.Text == "登录") { if (chKey.Checked == true) { StreamWriter sw = new StreamWriter(path, false); string data = txtuser.Text + "|" + txtpsw.Text; sw.WriteLine(data); sw.Close(); } webBrowser1.Navigate("http://172.16.200.17/login.asp"); txtuser.Text.Trim(); txtpsw.Text.Trim(); btnlogin.Text = "取消"; isExit1 = false; return; } else if(btnlogin.Text == "取消") { webBrowser1.Navigate("http://172.16.200.17/logout.asp"); btnlogin.Text = "登录"; return; } } private void cbSelect_SelectedIndexChanged(object sender, EventArgs e)//板块选择 { if(txtuser.Text==""&&txtpsw.Text=="") { MessageBox.Show("请先登录帐号!"); return; } webBrowser4.Navigate(url[cbSelect.SelectedIndex]); isExit4 = false; } public static string splitUrl(string szText)//获取新闻网址 { int i = 0; int nLen = szText.Length; for (; i < nLen; i++) { if (szText[i] == '"') { break; } } i++; string szURL = ""; for (; i < nLen; i++) { if (szText[i] == '"') { break; } szURL += szText[i]; } return szURL; } public static string splitTitle(string tiText)//获取新闻标题 { string szT = ""; if (!tiText.Contains("[")) { szT = tiText; } return szT; } private void webBrowser2_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (!isExit2) { try { HtmlDocument doc = webBrowser2.Document; for (int i = 0; i < doc.All.Count; i++) { ListViewItem myItem = new ListViewItem(); if (doc.All[i].TagName.ToLower().Equals("li")) { int len = doc.All[i].OuterText.Length; if (len > 20) { if (splitTitle(doc.All[i].OuterText) == "") { continue; } newUrl = splitUrl(doc.All[i].OuterHtml); newTitle = splitTitle(doc.All[i].OuterText); myItem = lvselect.Items.Add(newID.ToString()); myItem.SubItems.Add(newTitle); myItem.SubItems.Add(newUrl); newID++; } } } isExit2 = true; } catch { } } } private void lvselect_SelectedIndexChanged(object sender, EventArgs e) { int len = lvselect.Items.Count; newsCount = 0; textBox1.Text = ""; for (int i = 0; i < len; i++) { if (lvselect.Items[i].Selected == true) { txtID.Text = lvselect.Items[i].SubItems[0].Text; txtTitle.Text = lvselect.Items[i].SubItems[1].Text; newUrl = lvselect.Items[i].SubItems[2].Text; return; } } webBrowser3.ScriptErrorsSuppressed = true; //禁用错误脚本提示 switch (cbNews.Text) { case "TOM新闻频道": webBrowser3.Navigate(newUrl); break; case "中国新闻网": webBrowser3.Navigate("http://www.chinanews.com" + newUrl); break; } isExit3 = false; } private void btnrand_Click(object sender, EventArgs e) { if (lvselect.Items.Count == 0) { MessageBox.Show("请先选择新闻网站!"); return; } else { int select; newsCount = 0; textBox1.Text = ""; Random r = new Random(); select = r.Next(0, lvselect.Items.Count); txtID.Text = lvselect.Items[select].SubItems[0].Text; txtTitle.Text = lvselect.Items[select].SubItems[1].Text; newUrl = lvselect.Items[select].SubItems[2].Text; webBrowser3.ScriptErrorsSuppressed = true; //禁用错误脚本提示 switch (cbNews.Text) { case "TOM新闻频道": webBrowser3.Navigate(newUrl); break; case "中国新闻网": webBrowser3.Navigate("http://www.chinanews.com" + newUrl); break; } isExit3 = false; } } private void webBrowser3_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { string str = ""; if (!isExit3) { try { HtmlDocument doc = webBrowser3.Document; for (int i = 0; i < doc.All.Count; i++) { if (doc.All[i].TagName.ToLower().Equals("p")) { news[newsCount] = doc.All[i].OuterText;//合并内容 newsCount++; } } for (int i = 0; i < newsCount; i++) { str = str + news[i]; } textBox1.Text = str.Trim(); Clipboard.SetDataObject(textBox1.Text); groupBox3.Text = "新闻内容(已复制)"; isExit3 = true; } catch { } } } private void Form1_Load(object sender, EventArgs e) { //btnNews_Click(sender, e); StreamWriter sw = new StreamWriter(path, true); sw.Close(); StreamReader sr = new StreamReader(path); string line; string[] str = new string[3]; while ((line = sr.ReadLine()) != null) { str = line.Split('|'); txtuser.Text = str[0]; txtpsw.Text = str[1]; } } private void webBrowser4_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (!isExit4) { webBrowser4.Document.Window.ScrollTo(50, 500);//移动浏览器滚动条 HtmlDocument doc = webBrowser4.Document; HtmlElement ClickBtn = null; //HtmlElement ClickBtn2 = null; for (int i = 0; i < doc.All.Count; i++) { if (doc.All[i].TagName.ToString().Equals("INPUT")) { switch (doc.All[i].Name) { case "topic": doc.All[i].InnerText = txtTitle.Text; break; case "Submit": ClickBtn = doc.All[i]; //提交按钮 break; } } } //ClickBtn.InvokeMember("Click"); //执行按扭操作 isExit4 = true; } } private void textBox1_TextChanged(object sender, EventArgs e) { if (textBox1.Text == "") { groupBox3.Text = "新闻内容"; } } private void cbNews_SelectedIndexChanged(object sender, EventArgs e) { webBrowser2.ScriptErrorsSuppressed = true; //禁用错误脚本提示 switch(cbNews.Text) { case "TOM新闻频道": webBrowser2.Navigate("http://news.tom.com/"); break; case "中国新闻网": webBrowser2.Navigate("http://www.chinanews.com/" + newUrl); break; } isExit2 = false; } } } 注:这是山寨滴,,,,,, name:5+x