Javascript 使用Perl WWW:Mechanize的AJAX点击按钮

Javascript 使用Perl WWW:Mechanize的AJAX点击按钮,javascript,jquery,ajax,perl,Javascript,Jquery,Ajax,Perl,我正在为客户执行一个项目,他需要能够扫描特定页面上的目录。我已经修改了他的现有代码来运行循环,因为现在有多个页面可以从中提取内容。我试图从其中一页中浏览: 您可以看到,有162个页面似乎正在AJAX上运行,以加载下一批内容。现有代码将根据输入名称属性单击: ctl00$MainContent$GridCertificators$ctl00$ctl02$ctl00$ctl04 到目前为止,我的代码所做的只是刷新页面并扫描相同的内容162次 这是当前的代码段: use warnings; use W

我正在为客户执行一个项目,他需要能够扫描特定页面上的目录。我已经修改了他的现有代码来运行循环,因为现在有多个页面可以从中提取内容。我试图从其中一页中浏览:

您可以看到,有162个页面似乎正在AJAX上运行,以加载下一批内容。现有代码将根据输入名称属性单击:

ctl00$MainContent$GridCertificators$ctl00$ctl02$ctl00$ctl04 到目前为止,我的代码所做的只是刷新页面并扫描相同的内容162次

这是当前的代码段:

use warnings;
use WWW::Mechanize;
use Data::Dumper;
use HTML::TableExtract;
use Spreadsheet::WriteExcel;

#header();
# create max page array to handle civil and other page.
# number indicates how many times to click through
# first item in array is https://marriage.ag.gov.au/marriagecelebrants/civil
# second item is         https://marriage.ag.gov.au/marriagecelebrants/other
my @max_page_array = qw(
    162
    11
);

# create URL array for the 2 pages to scrape
my @url_array = qw(
    https://marriage.ag.gov.au/marriagecelebrants/civil
    https://marriage.ag.gov.au/marriagecelebrants/other
);
# get size of array
my $url_array_size = scalar @url_array;

# declare vars
my $n = 0;
my $i = 0;
# time to loop through the url's
while( $i < $url_array_size){
    open (raw, ">output-dev-$i.txt");
    close(raw);
    $n = 0;
    my $mech = WWW::Mechanize->new(autocheck => 1);
    $mech->get( $url_array[$i] );

    open (raw, ">>output-dev-$i.txt");
    while($n < $max_page_array[$i]){
        my $c = $mech->content;
        my $te = HTML::TableExtract->new(br_translate => 1,keep_html => 0);
        $te->parse($c);
        foreach my $ts ($te->tables) {
            foreach my $row ($ts->rows) {
                print raw join(',', @$row);
            }
        }

       #this was existing code
       #$mech->click( "ctl00\$MainContent\$gridCelebrants\$ctl00\$ctl02\$ctl00\$ctl04" );

       #tried multiple variations based on documentation and got nowhere
       $mech->click_button( 'ctl00$MainContent$gridCelebrants$ctl00$ctl02$ctl00$ctl04' );
       $n++;
    }
    close raw;
    $i++;
} # while loop - url array size 
使用警告;
使用WWW::Mechanize;
使用数据::转储程序;
使用HTML::TableExtract;
使用电子表格::WriteExcel;
#标题();
#创建最大页面数组以处理civil和其他页面。
#数字表示点击次数
#数组中的第一项是https://marriage.ag.gov.au/marriagecelebrants/civil
#第二项是https://marriage.ag.gov.au/marriagecelebrants/other
我的@max_页面_数组=qw(
162
11
);
#为要刮取的2个页面创建URL数组
我的@url\u数组=qw(
https://marriage.ag.gov.au/marriagecelebrants/civil
https://marriage.ag.gov.au/marriagecelebrants/other
);
#获取数组的大小
my$url\u array\u size=scalar@url\u array;
#申报VAR
我的$n=0;
我的$i=0;
#是时候在url的
而($i<$url\u数组\u大小){
打开(原始,“>输出开发-$i.txt”);
关闭(原始);
$n=0;
我的$mech=WWW::Mechanize->new(自动检查=>1);
$mech->get($url_数组[$i]);
打开(原始,“>>输出开发-$i.txt”);
而($n<$max\u page\u数组[$i]){
我的$c=$mech->内容;
我的$te=HTML::TableExtract->new(br\u translate=>1,keep\u HTML=>0);
$te->parse($c);
foreach my$ts($te->表格){
foreach my$行($ts->行){
打印原始联接(“,”,@$行);
}
}
#这是现有的代码
#$mech->单击(“ctl00\$MainContent\$GridCertablets\$ctl00\$ctl02\$ctl00\$ctl04”);
#尝试了基于文档的多种变体,但一无所获
$mech->click_按钮('ctl00$MainContent$GridCellements$ctl00$ctl02$ctl00$ctl04');
$n++;
}
近生;
$i++;
}#while循环-url数组大小
我的问题是,当您单击next时,如何让我的perl脚本加载下一页并扫描下一组数据

我的问题是,当您单击next时,如何让我的perl脚本加载下一页并扫描下一组数据

根据,不支持JavaScript。它提供了一个可执行的功能,另请参见