和@陈宇翔的修行录忙了一个星期写了个刷票器来交软件测试课的作业
PPT不是很好传,放到资源里面去,PPT地址:
源码地址:http://download.csdn.net/detail/a8887396/5344103
投票效果:
刷票地址: (有效期半年)
http://mwangbobo.jingdianet.com/Default.aspx
主要代码:
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.IO;
using mshtml;
using System.Net;
using System.Runtime.InteropServices;
namespace 刷票
{
public partial class Form1 : Form
{
[DllImport(@"wininet",
SetLastError = true,
CharSet = CharSet.Auto,
EntryPoint = "InternetSetOption",
CallingConvention = CallingConvention.StdCall)]
//即时刷新IE设置
public static extern bool InternetSetOption(
int hInternet,
int dmOption,
IntPtr lpBuffer,
int dwBufferLength
);
//是否可以连接到internet
[DllImport("wininet.dll")]
public extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
//返回false就是能连接到internet
public static bool IsConnectedToInternet()
{
int Desc; return InternetGetConnectedState(out Desc, 0);
}
int count_all = 0; //投票次数
bool is_start = false; //开始标志
bool is_interval = false; //是否使用时间间隔
bool is_proxy = false;
// bool is_ip_changed = false;
string url_str = "http://mwangbobo.jingdianet.com/Default.aspx"; //投票的指定网址
// string url_str = "http://localhost:4128/WebSite1/Default.aspx";
string file_path; //代理IP的文本路径
string[] ip = new string[1024]; //代理IP
// string[] port = new string[1024]; //代理IP的端口
int count_ip = 0; //代理IP个数
public Form1()
{
InitializeComponent();
webBrowser1.Navigate(url_str); //跳转到页面
}
/* ================== 投票模块 ================== */
//点击开始按钮
private void btn_start_Click(object sender, EventArgs e)
{
if (!IsConnectedToInternet()) //检查网卡状态 是否连接到internet 如你把网线拔了就会出错, 不包括设置代理IP错误导致不能开网页的情况
{
MessageBox.Show("不能连接到internet");
return;
}
// if (is_start || webBrowser1.Url == null || webBrowser1.Url.ToString() != url_str) //开始之后不能再点开始无效 或者 当前页面不是投票页面无效
{
//