Closed 532910 closed 9 months ago
do you mean with the $firefox->pdf()
method, or by going directly to a pdf url, like $firefox->go("https://$hostname/$path.pdf);
yep, $firefix->pdf
method
okay, probably the best option is to retrieve the page and then use the $firefox->har()
method to extract the session and search for the url(s) that make up the page. Does that work?
It sounds hard, there are no libarchive-har-perl in debian, trying to Dumper( $firefox->pdf )
gives: Perl: javascript error: ReferenceError: HAR is not defined
Is it possible to get http status code from firefox after Navigate
(and provide it as $firefox->status_code()
)?
libarchive-har-perl makes things a bit nicer, but what you are trying to achieve can be done with
use strict;
use warnings;
use Firefox::Marionette();
my $url = 'https://www.google.com/';
my $firefox = Firefox::Marionette->new(har => 1);
$firefox->go($url);
foreach my $entry (@{$firefox->har()->{log}->{entries}}) {
if ($entry->{request}->{url} eq $url) {
if ($entry->{response}->{status} == 200) {
warn "Printing successful page";
$firefox->pdf();
}
}
}
does that look ok?
yes, though I'd checked all statues:
my @statuses = map { $_->{response}->{status} } @{$firefox->har->{log}->{entries}};
if( @statuses == grep { $_ eq 200 } @statuses ) ...
and https://github.com/david-dick/firefox-marionette/issues/32 ):
Thank you, @david-dick!
I'd like to make pdf, but only if 200 was returned. If server returns 404 or 503 for example, pdf just prints page with "404" or "503" text.