Perl script for IE automation
来源:互联网 发布:python社交数据可视化 编辑:程序博客网 时间:2024/04/27 13:44
# Here is a little script that I wrote to do some automatic URL browsing using IE
# what it does is to read proxy server and port from a text named "proxylist.txt", under the same dir,
# then test if that port is active, if it is, then set it as IE's proxy, then it fires IE and browse the url picked #randomly from an array @url; then close IE.
#
# This script runs on Winodws with activestate perl installed. Also you need to install #Win32::IEAutomation module.
#
# proxylist.txt formate should be like the following:
#145.123.202.56 3128
#234.80.225.37 8080
use Win32::IEAutomation::WinClicker;
use Win32::IEAutomation;
use strict;
use Win32::TieRegistry ( Delimiter=>"/", ArrayValues=>1 );
use Net::Ping;
my $path = "proxylist.txt";
my $ie = Win32::IEAutomation->new( visible => 1, maximize => 1);
my @url = (
"http://blog.csdn.net/bsdplus/",
"http://blog.csdn.net/bsdplus/archive/2008/04/16/2296812.aspx",
"http://alan.blogcn.com",
"http://alan0203.blogspot.com",
"http://blog.csdn.net/bsdplus/archive/2007/10/22/1836987.aspx",
"http://blog.csdn.net/bsdplus/archive/2008/04/13/2289361.aspx",
"http://blog.csdn.net/bsdplus/archive/2008/04/14/2290446.aspx",
"http://alan0203.blogspot.com/2008/04/use-proxy-authentication-with-perl.html",
"http://alan0203.blogspot.com/2007/05/pcbsd-intel.html",
"http://alan0203.blogspot.com/2007/05/fcitx-pcbsd.html",
"http://alan0203.blogspot.com/2007/05/pcbsd_08.html",
"http://alan0203.blogspot.com/2007/05/windowswinxppcbsd.html",
"http://alan0203.blogspot.com/2007/05/winxppcbsd.html",
"http://alan0203.blogspot.com/2007/05/blog-post.html"
); # end of url array
open(P_SOURCE, "<", $path)
or die "Couldn't open $path for reading: $! "; #open txt file to read proxy list;
our @proxys = <P_SOURCE>;
my $waitSeconds = 2;
my $proxy_title = "Connect to myproxy.org";
my $wait_time = 1;
&set_IE_Proxy();
# start Site navigation
my $myurl = @url[int(rand(9))]; #pick a url at random;
sleep(int(rand(120)));
$ie->gotoURL($myurl,$waitSeconds);
# uncomment the following if your proxy requires username/password and if ALREADY has them cached.
# my $clicker = Win32::IEAutomation::WinClicker->new( warnings => 1);
# $clicker->push_confirm_button_ok($proxy_title, $wait_time);
$ie->WaitforDone();
print " URL is: $myurl ";
sleep(15);
$ie->closeIE();
# close(P_SOURCE);
sub set_IE_Proxy() {
my $proxy_pick = 1 + int(rand(@proxys));
print " $proxy_pick is $proxy_pick ";
my @SvrPtCn = split(" ", $proxys[$proxy_pick]); # split line into words;
print "Proxy server pick is : $SvrPtCn[0]:$SvrPtCn[1] ";
my $server = $SvrPtCn[0];
my $port = $SvrPtCn[1];
my $enable= 1 ;
my $override= "127.0.0.1;<local>";
################################################################
# start TCP PING to see if the proxy is active on specified port
my $test = Net::Ping->new('tcp', 5);
$test->{port_num} =$port;
if (! $test->ping($server)) {
print "$server:$port isn't serving HTTP! ";
&set_IE_Proxy();#next;
} else {
print "TCP Ping test ok! Setting IE proxy to $server:$port...... ";
my $rkey=$Registry->{"CUser/Software/Microsoft/Windows/CurrentVersion/Internet Settings"};
$rkey->SetValue("ProxyServer", "$server:$port", "REG_SZ");
$rkey->SetValue("ProxyEnable",pack("L",$enable), "REG_DWORD");
$rkey->SetValue("ProxyOverride", $override, "REG_SZ");
print "IE proxy set. ";
};
}; # end of sub set_IE_proxy();
- Perl script for IE automation
- A perl script for XSLT using MSXML
- MSHTML Event DispInterfaces(For Hosting or Automation IE)
- sftp automation script
- Perl和OLE Automation
- How to generate exe for your PERL script?
- Automation test script kickoff system
- Siebel Issue: Browser script doesn't work for IE
- [PERL]G-Injector Perl Script
- compile perl script
- perl monitor script积累
- Database SQL script automation management tools investigation
- IE script debug 工具
- perl script.pl vs perldoc script.pl
- Sample Perl script
- preProcessPsa perl script
- Appium for Andriod Automation Test
- good example for web automation and exe automation
- 时刻拓展
- 在青鸟的第一次竞聘
- zju 2529 DomiNo Grid
- Windows XP SP3 RTM 简体中文版!!!
- 如何删除数据库中重复纪录
- Perl script for IE automation
- 我遇到的一个BUG(一)
- 转一篇李承鹏的博文“CNN患了口蹄疫吗”,个人认为很不错
- 微软的面试题及答案
- 抗美援朝:我军在朝鲜战场上歼敌最多的部队
- 后阿里巴巴时代:从消费资本化理论“望远镜”中探视——电子商务发展趋势探析之一
- 创新
- 歙县昌溪的百个看点
- 再谈引用与指针的区别