C#设置代理IP及刷网站访问量demo
来源:互联网 发布:pc机与单片机通讯协议 编辑:程序博客网 时间:2024/05/16 06:39
二话不说先上图:
浏览网站用的是webBrowser,使用timer进行延迟访问网址,获取代理ip列表通过解析ip代理网址获取和文件夹方式StreamReader ReadLine获取。
增加了个小功能用委托能够在listbox里面看到当前访问的ip(蓝色条,可动)
设置代理ip是参考网上的资料,下面是设置代理ip代码:
public Boolean setip(string ip){ RefreshIESettings(ip); IEProxy ie = new IEProxy(ip); return ie.RefreshIESettings();} public struct Struct_INTERNET_PROXY_INFO { public int dwAccessType; public IntPtr proxy; public IntPtr proxyBypass; };private void RefreshIESettings(string strProxy) { const int INTERNET_OPTION_PROXY = 38; const int INTERNET_OPEN_TYPE_PROXY = 3; const int INTERNET_OPEN_TYPE_DIRECT = 1; 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)); if (string.IsNullOrEmpty(strProxy) || strProxy.Trim().Length == 0) { strProxy = string.Empty; struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_DIRECT; } // Converting structure to IntPtr Marshal.StructureToPtr(struct_IPI, intptrStruct, true); bool iReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, Marshal.SizeOf(struct_IPI)); } [DllImport("wininet.dll", SetLastError = true)] private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength); public class IEProxy { private const int INTERNET_OPTION_PROXY = 38; private const int INTERNET_OPEN_TYPE_PROXY = 3; private const int INTERNET_OPEN_TYPE_DIRECT = 1; private string ProxyStr; [DllImport("wininet.dll", SetLastError = true)] private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength); public struct Struct_INTERNET_PROXY_INFO { public int dwAccessType; public IntPtr proxy; public IntPtr proxyBypass; } private bool InternetSetOption(string strProxy) { int bufferLength; IntPtr intptrStruct; Struct_INTERNET_PROXY_INFO struct_IPI; if (string.IsNullOrEmpty(strProxy) || strProxy.Trim().Length == 0) { strProxy = string.Empty; struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_DIRECT; } else { struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY; } struct_IPI.proxy = Marshal.StringToHGlobalAnsi(strProxy); struct_IPI.proxyBypass = Marshal.StringToHGlobalAnsi("local"); bufferLength = Marshal.SizeOf(struct_IPI); intptrStruct = Marshal.AllocCoTaskMem(bufferLength); Marshal.StructureToPtr(struct_IPI, intptrStruct, true); return InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, bufferLength); } public IEProxy(string strProxy) { this.ProxyStr = strProxy; } //设置代理 public bool RefreshIESettings() { return InternetSetOption(this.ProxyStr); } //取消代理 public bool DisableIEProxy() { return InternetSetOption(string.Empty); } }
0 0
- C#设置代理IP及刷网站访问量demo
- 【Python3.6爬虫学习记录】(十一)使用代理IP及用多线程测试IP可用性--刷访问量
- 网站访问量及在线人数
- 轻松切换IP及IE代理设置
- 轻松切换IP及IE代理设置
- 轻松切换IP及IE代理设置
- python抓取某代理网站代理IP及端口
- 网站访问量统计之UV/PV/IP
- 筛选出可用的代理+刷百度博客访问量+ip正则表达式
- C# 设置IP地址及设置自动获取IP
- 代理ip 网站
- 抓取 网站 代理 ip
- 代理ip的网站
- c#百度排名点击器编写,设置代理ip
- 3招轻松查看别人网站的ip访问量-如何查看网站访问量教程(转)
- HttpClient代理IP及设置连接读取超时
- 怎么样设置代理IP
- VC 设置代理IP
- java中this和super的用法
- ubuntu下安装SCons
- 500、Linux获取随机密码
- ABAP 提取或去除字符串中的中文字符(双字节字符)
- bzoj3917 && apio2016练习赛T2 题解
- C#设置代理IP及刷网站访问量demo
- $("#test") 与 document.getElementById("test') 不一样 !
- C中不能省略形参名字
- caffe学习笔记:1、Training LeNet on MNIST with Caffe
- UVa Problem 100 The 3n+1 problem (3n+1 问题)+1 问
- 用exe4j+Inno_setup打包java桌面应用
- Leetcode no. 299
- sublime text 2 安装catgs函数追踪插件
- JAVA实现二叉树的遍历的非递归算法及递归算法(前序,中序,后序,层次)