我正在使用WWW::Scripter抓取一个用javascript/ajax编写的页面,指向下一页的“链接”是一个div标记,我可以获得该标记,但似乎想不出一种方法来单击它以转到下一页……有什么建议吗?
my $w = new WWW::Scripter;
$w->use_plugin('Ajax');
$w->get($c->website);
my $loop = 1;
my $page = 1;
while ($loop) {
my $te = HTML::TableExtract->new();
$content = $w->content();
$te->parse($content);
$table = $te->first_table_found;
$str .= Dumper $table;
$page += 1;
$loop = $self->next_page($w);
}
sub next_page {
my $self = shift;
my $w = shift;
$div = $w->document->getElementById('example_next');
if (defined $div) {
--I want to click on the div and move to the next page, suggestions?---
return 1;
} else {
return 0;
}
}示例html代码...首先有一个保存数据的表……
<table class="display" id="example">
<thead>
headers
</thead>
<tbody>---DATA---</tbody>
</table>然后分页从"page“到"page”每次点击分页都会重写数据。
<div class="dataTables_paginate paging_two_button" id="example_paginate">
<div class="paginate_disabled_previous" title="Previous" id="example_previous"></div>
<div class="paginate_enabled_next" title="Next" id="example_next"></div>
</div>这都是使用www.datatables.net实现的
发布于 2012-11-06 06:20:23
您需要确定在单击该div的id时发生的JavaScript调用,然后执行它。或者,您可以使用WWW::Mechanize::Firefox或WWW::Selenium。
https://stackoverflow.com/questions/13239066
复制相似问题