Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用perl打开和关闭网页_Perl_Webpage - Fatal编程技术网

使用perl打开和关闭网页

使用perl打开和关闭网页,perl,webpage,Perl,Webpage,我想写的脚本,以自动帮助我预订一个网站的时间槽。由于我想像周一到周五那样预订,我编写的脚本将在浏览器中弹出五个选项卡,通过system(“start$book”)完成预订后我可以关闭选项卡吗?下面是我的示例代码 use Time::Local; use POSIX; ####### this week ########## my $today = time (); my $seconds = 24*60*60; my @gmtime = gmtime (); my@thisweek; $t

我想写的脚本,以自动帮助我预订一个网站的时间槽。由于我想像周一到周五那样预订,我编写的脚本将在浏览器中弹出五个选项卡,通过
system(“start$book”)
完成预订后我可以关闭选项卡吗?下面是我的示例代码

use Time::Local;
use POSIX;


####### this week ##########

my $today = time ();
my $seconds = 24*60*60;
my @gmtime = gmtime ();
my@thisweek;
$today = $today - $gmtime[6] * $seconds;
for my $haha (0..4) {
    $today += $seconds;
    my @wday = gmtime ($today);
    push @thisweek,strftime ("%Y%m%d %Y%U", @wday);
}

($monday_1,$tuesday_1,$wednesday_1,$thursday_1,$friday_1) = @thisweek; 

book_time($monday_1,"1617");
book_time($tuesday_1,"1617");
book_time($wednesday_1,"1617");
book_time($thursday_1,"1617");
book_time($friday_1,"1617");

sub book_time()
{
my ($bookdate,$bookweek)= split " ",shift;
my $booktime= shift;
my $book = "http://www.example.com";
system("start $book");
}
使用它可以操作应用程序本身

如何使用此功能的示例:

use strict;
use warnings;
use Win32::OLE

my $my_page = Win32::OLE->new("InternetExplorer.Application"); # sets the app to open (IE)
   $my_page->{visible} = 1;    # sets whether the action is visible
   $my_page->Navigate("http://www.example.com"); # opens the page
   # ..do something while page is open...
   $my_page->Quit(); # close the page when done.
显然,如果您没有安装
Win32::OLE
模块,您需要通过从cmd运行
cpan install Win32::OLE
来安装该模块。

使用您操作应用程序本身

如何使用此功能的示例:

use strict;
use warnings;
use Win32::OLE

my $my_page = Win32::OLE->new("InternetExplorer.Application"); # sets the app to open (IE)
   $my_page->{visible} = 1;    # sets whether the action is visible
   $my_page->Navigate("http://www.example.com"); # opens the page
   # ..do something while page is open...
   $my_page->Quit(); # close the page when done.

显然,如果您没有安装
Win32::OLE
模块,那么您需要通过从cmd运行
cpan install Win32::OLE
来安装该模块。

为什么不使用它,然后您可以在完成后退出?您好@GerhardBarnard,我是perl新手,不确定如何在我的脚本中使用该
Win32::OLE
,您能给我举个例子吗?谢谢在下面的答案中看到一个简单的演示。您可以在页面上找到更多帮助查看WWW::Mechanize::Firefox和WWW::Mechanize::Chrome。有了这些,您可以轻松地自动构建整个预订流程。或者,如果您真的想从脚本中控制web浏览器,为什么不使用,那么您可以在完成后退出?您好@GerhardBarnard,我是perl新手,不知道如何在我的脚本中使用此
Win32::OLE
,您能给我举个例子吗?谢谢在下面的答案中看到一个简单的演示。您可以在页面上找到更多帮助查看WWW::Mechanize::Firefox和WWW::Mechanize::Chrome。有了这些,您可以轻松地自动构建整个预订流程。或者,如果您真的想通过脚本控制web浏览器。您好,我已经尝试了上面的代码,但这次弹出了一个新的IE窗口,窗口没有关闭。您现在可以再试一次吗?可以,我尝试其他网站,但它的工作,因为我想达到的网站是在.cgi格式,所以我认为是我想达到的网站的问题。谢谢。。cgi是perl,也许看看其他的get请求?可以使用哪种get请求?嗨,我已经尝试了上面的代码,但是这次弹出了一个新的IE窗口,窗口没有关闭。你现在可以再试一次吗?是的,我尝试了其他网站,它可以工作,但是因为我想访问的网站是.cgi格式的,所以我认为这是我想要访问的网站的问题。谢谢。。cgi是perl,也许可以看看其他get请求?可以使用哪种get请求?