2016-01-26 39 views
0

我在廢除site,我正在尋找代碼示例來幫助我找出如何檢索這個JSP控件內部的信息(比使用普通文本困難得多)。我似乎沒有找到任何與HTTP標頭。這是我的代碼到目前爲止:使用perl來刮擦網站的JS內容

my $mech_r = new WWW::Mechanize(); 

my $uri = 'http://global.krx.co.kr/contents/GLB/02/0203/0203000000/GLB0203000000.jsp'; 
print "Getting '$uri'\n"; 
my $page = $mech_r->get($uri); 

print "Parsing data..."; 
my $root = HTML::TreeBuilder->new_from_content($mech_r->content()); 

my ($news_table) = $root->look_down(
    sub { 
     defined($_[0]->tag()) and 
     $_[0]->tag() eq 'ul' and 
     defined($_[0]->attr('class')) and 
     $_[0]->attr('class') eq 'board-list' 
    } 
); 

if (!defined($news_table)) { 
    print Dumper($root); 

    croak "Could not get the news table"; 
} 

我想獲得標題,日期和鏈接。

但是沒有得到任何數據,因爲它是由JavaScript加載。

回答