你的位置:首页 > ASP.net教程

[ASP.net教程]狗扑论坛 自动刷取VIP狗粮


狗扑论坛 自动刷取VIP狗粮

开始闲狗粮回复太慢就自己想了想去写一个,成功总是给我的哈哈。

自己花了一小时 时间慢慢学就慢慢写的  虽然代码简单 但是已经够自己用了

 

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;namespace WindowsFormsApplication1{  public partial class Form1 : Form  {    public Form1()    {      InitializeComponent();    }        private void Form1_Load(object sender, EventArgs e)    {      var request = (HttpWebRequest)WebRequest.Create("http://bbs.goupu.org/member.php?mod=logging&action=login"); //Create:创建WebRequest对象       webBrowser1.Document.Encoding = "UTF-8"; //解决网页乱码      //HttpWebResponse对象实例:该类用于获取和操作HTTP应答 var可改成HttpWebResponse       var response = (HttpWebResponse)request.GetResponse(); //GetResponse:获取答复       //构造数据流对象实例       Stream stream = response.GetResponseStream();//GetResponseStream:获取应答流       StreamReader sr = new StreamReader(stream); //从字节流中读取字符             //从流当前位置读取到末尾并显示在WebBrower控件中       string content = sr.ReadToEnd();      webBrowser1.DocumentText = content;      HtmlElement user = webBrowser1.Document.All["username"];      HtmlElement pass = webBrowser1.Document.All["password"];      HtmlElement but = webBrowser1.Document.All["loginsubmit"];      if(user==null||pass==null||but==null)      {        return;      }      user.SetAttribute("value", "用户名");      pass.SetAttribute("value","密码");      MessageBox.Show(user.ToString());      but.InvokeMember("Click");    }    private void button1_Click(object sender, EventArgs e)    {      HtmlElement text = webBrowser1.Document.All["message"];      text.SetAttribute("value","+10袋狗粮");      HtmlElement but = webBrowser1.Document.GetElementById("postsubmit");      but.InvokeMember("Click");    }    private void button2_Click(object sender, EventArgs e)    {      timer1.Enabled = true;      timer1.Interval=1000;      timer1.Start();        HtmlElement img = webBrowser1.Document.GetElementById("fastpostmessage");        img.SetAttribute("value", "+10袋狗粮");        HtmlElement but1 = webBrowser1.Document.All["replysubmit"];        but1.InvokeMember("Click");        timer1.Stop();    }  }}