大家都知道网上有很多投票功能.于是就有了刷票数的软件,这几天了解一下,其思路应该是每刷几次网页,就更换一个IP,然后继续访问.防止IP被封掉.刷机无效.....
在这里我用winfrom写了一更换ip去打开网页的demo,(只是实现了核心的东西,以后有时间在改下.有兴趣的朋友可以弄下)后续开发大概是.从网上抓取免费的代理ip,然后在设定一个时间间隔.每隔多少次刷一下,和每隔多少次(多少秒)换一个ip..
界面大概这样
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
void ShowWeb()
{
//这里的地址我写死.以后有时间在搞吧
webBrowser1.Navigate("http://www.ip138.com/");
}
#region 改变代理
[DllImport("wininet.dll", SetLastError = true)]
private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength);
public void RefreshIESettings(string strProxy)
{
const int INTERNET_OPTION_PROXY = 38;
const int INTERNET_OPEN_TYPE_PROXY = 3;
Struct_INTERNET_PROXY_INFO struct_IPI;
// Filling in structure
struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
struct_IPI.proxy = Marshal.StringToHGlobalAnsi(strProxy);
struct_IPI.proxyBypass = Marshal.StringToHGlobalAnsi("local");
// Allocating memory
IntPtr intptrStruct = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI));
// Converting structure to IntPtr
Marshal.StructureToPtr(struct_IPI, intptrStruct, true);
bool iReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, Marshal.SizeOf(struct_IPI));
}
struct Struct_INTERNET_PROXY_INFO
{
public int dwAccessType;
public IntPtr proxy;
public IntPtr proxyBypass;
}
#endregion
/// <summary>
/// 更换IP访问
/// </summary>
/// <param></param>
/// <param></param>
private void button1_Click(object sender, EventArgs e)
{
RefreshIESettings(textBox1.Text);
ShowWeb();
}
/// <summary>
/// 切回本机IP
/// </summary>
/// <param></param>
/// <param></param>
private void button2_Click(object sender, EventArgs e)
{
IPAddress localIp = IPAddress.Parse("127.0.0.1");
IPEndPoint iep = new IPEndPoint(localIp, 80);
RefreshIESettings(iep.ToString());
}
}