简体   繁体   中英

How to get an HTML table from the document using WWW::Mechanize::Firefox

I don't understand how to access an HTML table from a document.

I am playing with this link: Scotia Bank Jobs

The idea is to click on "Next page" button several times and gather all small HTML tables into one.

When I open the link with WWW::Mechanize::Firefox , I can get the whole document (and first page HTML table) with

 my $cont= $mech->content( format => 'html' );

After that I click on "Next page" button with

my $id="search_result_next_page_link"; 
$mech->click({ xpath => qq{//*[\@id="$id"]}, synchronize => 0 }); 

I can click the button many times and the table is being changed inside the document, but I can not use $mech->content any more, because the URL is the same and content is not changing.

I was trying something like :

my $tt= $mech->xpath('/html/body/form/div[4]/div/main/div/div[3]/section/div/div/table/text()');
print $tt;

but it prints "0".

I have a feeling that I am very close, any idea how to get HTML table after every click????

Finally....I had to bother the author of the WWW::Mechanize::Firefox module and he provided with the solution how to get the HTML code of this table. Script should be something like this:

@tt= $mech->selector('.tableSearchResults'); $HTMLtable= $tt[0]->{innerHTML};

Don't forget, you need to wait after every click (or create a cycle, waiting for the element to show up).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM