如果一个ip在一段时间过多的注册,则该ip会被封调,一个办法就是修改注册表以修改代理服务器。在这里我使用一个api函数internetsetoption,使用之前要添加一个模块,然后加入如下代码:
public const internet_option_proxy = 38
public const internet_open_type_proxy = 3
public const internet_option_settings_changed = 39
type internet_proxy_info
dwaccesstype as long
lpszproxy as string
lpszproxybypass as string
end type
public declare function internetsetoption lib "wininet.dll" _
alias "internetsetoptiona" _
(byval hinternet as long, _
byval dwoption as long, _
byref lpbuffer as any, _
byval dwbufferlength as long) as long
改代码定义了三个常数和一个结构,该api函数的具体用法请大家查询msdn。vb修改注册表的办法就太多了,我就不多说了。在webbrowser1_documentcomplete事件中在添加一个条件语句,用以判断是否是ip被封的提示页面,代码如下:
if instr(doc.body.innertext, "ip地址在这一段时间内已经注册了太多的用户") > 0 then
dim options as internet_proxy_info
options.dwaccesstype = internet_open_type_proxy
options.lpszproxy = "168.10.46.77:80"
options.lpszproxybypass = ""
internetsetoption 0, internet_option_proxy, options, lenb(options)
dim don as double
dim doff as double
set reg = createobject("wscript.shell")
a = reg.regwrite("hkey_current_user\software\microsoft\windows\currentversion\internet settings\proxyserver", _
"211.144.96.250:80")
a = reg.regwrite("hkey_current_user\software\microsoft\windows\currentversion\internet settings\proxyenable", _
1)
internetsetoption 0, internet_option_settings_changed, 0, 0
webbrowser1.navigate "http://freemail.eyou.com/signup.html?bgp=%ce%d2%bd%d3%ca%dc&bgp_enable=on"
end if
至此代理服务器的修改也完成了。
对于一些有验证码的网站如何识别出图片上的验证码,我还没有办法解决,我试着用vc写了一个图片识别程序,但效果很不理想,希望大家多交流。
