網頁自動登入,自動填滿表單代碼

來源:互聯網
上載者:User

標籤:blog   os   for   art   ar   div   代碼   html   

實現自動登入某網站,並且登入完成後跳轉到指定的頁面。然後進行表單的自動填滿表單提交 。類型於小型的發帖機  哈哈 (看官在看下面代碼的時候,把記得把下面的連結改下)
public partial class Form1 : Form { public Form1() { InitializeComponent(); webBrowser1.Navigate("www.tiantianit.com"); } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (webBrowser1.Url.ToString() == "www.tiantianit.com") { webBrowser1.Document.All["username"].InnerText = "[email protected]"; webBrowser1.Document.All["password"].InnerText = "wl58500290"; //webBrowser1. HtmlElement tem = null; var tem111 = webBrowser1.Document.GetElementsByTagName("input"); for (int i = 0; i < tem111.Count; i++) { HtmlElement aaaa = tem111[i]; if (aaaa.GetAttribute("type") == "button") { tem = aaaa; } } tem.InvokeMember("click"); Thread.Sleep(1000); webBrowser1.Navigate("www.tiantianit.com");//登陸成功後轉到寫blog this.Show(); //bool isLogIn = false; //if (webBrowser1.Url.ToString() == "www.tiantianit.com") //{ // System.Windows.Forms.MessageBox.Show("使用者名稱或密碼錯誤!"); // return; //} //else //{ // //isSetForm = false; // //mylogin.Close(); // webBrowser1.Navigate("www.tiantianit.com"); // this.Show(); //} } if (webBrowser1.Url.ToString() == "www.tiantianit.com") { webBrowser1.Document.All["txtTitle"].InnerText = "hello 我的第一篇部落格"; webBrowser1.Document.All["editor"].InnerText = "hello 我的第一篇部落格"; //var tem111 = webBrowser1.Document.GetElementsByTagName("body"); //HtmlElement bbbb = null; //for (int i = 0; i < tem111.Count; i++) //{ // HtmlElement aaaa = tem111[i]; // if (aaaa.GetAttribute("class") == "editMode") // { // bbbb = aaaa; // } //} //bbbb.InnerHtml = "hello 我的第一篇部落格"; webBrowser1.Document.GetElementById("selType").SetAttribute("innerHTML", "轉載"); webBrowser1.Document.GetElementById("txtTag2").InnerText = "asp.net";//標題 webBrowser1.Document.GetElementById("txtTag").InnerText = "asp.net";//內容 HtmlElement authortb = webBrowser1.Document.All["radChl2"]; authortb.SetAttribute("checked", "checked"); } } }

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.