new results in my trials to install WWW::Mechanize::FireFox

Einfach Dinge, die nichts mit XAMPP, Apache Friends, Apache, MySQL, PHP und alle dem zu tun haben. Allerlei halt. ;)

new results in my trials to install WWW::Mechanize::FireFox

Postby unleash » 11. November 2012 20:04

i will do all you advice.

as for now: here some more insights: see the folliwing


i ve set up another notebook with opensuse - and as i have had various errors with the make - i installed gcc this time. And with this i got more propper results:


[PHP]cpan[4]> install WWW::Mechanize::Firefox
WWW::Mechanize::Firefox is up to date (0.68).
[/PHP]


After the installation i used several scripts from the Mechanize-Examples (see here
http://search.cpan.org/~corion/WWW-Mech ... xamples.pm )

And i would say that those results were really a bit better than all i got untill now. See the terminal-results - and the corresponding code below...

example3

Code: Select all

martin@linux-ale9:~/perl> perl exa3.pl
Bareword found where operator expected at exa3.pl line 61, near "--current"
        (Missing operator before current?)
Bareword found where operator expected at exa3.pl line 63, near "--mozrepl"
        (Missing operator before mozrepl?)
Bareword found where operator expected at exa3.pl line 65, near "--type"
        (Missing operator before type?)
Number found where operator expected at exa3.pl line 69, near "over 4"
        (Do you need to predeclare over?)
Bareword found where operator expected at exa3.pl line 106, near "The"
        (Missing semicolon on previous line?)
Bareword found where operator expected at exa3.pl line 107, near "at"
        (Missing semicolon on previous line?)
syntax error at exa3.pl line 51, near "="
"use" not allowed in expression at exa3.pl line 73, at end of line
"use" not allowed in expression at exa3.pl line 95, at end of line
Execution of exa3.pl aborted due to compilation errors.
martin@linux-ale9:~/perl>





example5
Code: Select all
martin@linux-ale9:~/perl> perl exa5.pl
Can't find string terminator "JS" anywhere before EOF at exa5.pl line 4.
martin@linux-ale9:~/perl> perl exa6.pl
Failed to connect to , Couldn't load "MozRepl::Plugin::Base", "Attempt to reload MozRepl/Plugin/Base.pm aborted.
Compilation failed in require at /usr/lib/perl5/site_perl/5.16.0/Module/Pluggable/Fast.pm line 82.
" at /usr/lib/perl5/site_perl/5.16.0/Module/Pluggable/Fast.pm line 84.



example6

Code: Select all
martin@linux-ale9:~/perl> perl exa6.pl
Failed to connect to , Couldn't load "MozRepl::Plugin::Base", "Attempt to reload MozRepl/Plugin/Base.pm aborted.
Compilation failed in require at /usr/lib/perl5/site_perl/5.16.0/Module/Pluggable/Fast.pm line 82.
" at /usr/lib/perl5/site_perl/5.16.0/Module/Pluggable/Fast.pm line 84.



see the corresponding code - that i have taken from the above mentioned site.

example-code 3
Code: Select all
    GetOptions(
        'mozrepl|m:s' => \my $mozrepl,
        'tab:s' => \my $tab,
        'current|c' => \my $use_current_tab,
        'close|q' => \my $close,
        'title|t:s' => \my $title,
        'type:s' => \my $encode_type,
        #'focus|f' => \my $focus,
    ) or pod2usage();
   
    $tab = $use_current_tab ? 'current'
           : $tab ? qr/$tab/
           : undef
           ;
   
    $title ||= getcwd;
   
    my $mech = WWW::Mechanize::Firefox->new(
        tab     => $tab,
        repl    => $mozrepl,
        create  => 1,
        autoclose => $close,
    );
   
    local $/;
    binmode STDIN;
    my $html = <>;
   
    # Find out whether we have HTML:
    if (! $encode_type) {
        if ($html =~ /^\s*</sm) {
            $encode_type = 'html'
        } else {
            $encode_type = 'text',
        };
    };
   
    if ('text' eq $encode_type) {
        my %map = (
        '<' => '&lt;',
        '>' => '&gt;',
        '&' => '&amp;',
        );
        $html =~ s/([<>&])/$map{$1} || $1/ge;
        $html =~ s/\r?\n/<br>/g;
        $html = "<html><head><title>$title</title><body><pre>$html</pre></body></html>";
    };
   
    $mech->update_html($html);
   
    =head1 NAME
   
    bcat.pl - cat HTML to browser
   
    =head1 SYNOPSIS
   
      bcat.pl <index.html
   
    Options:
       --tab            title of tab to reuse (regex)
       --current        reuse current tab
       --title          title of the page
       --mozrepl        connection string to Firefox
       --close          automatically close the tab at the end of input
       --type TYPE      Fix the type to 'html' or 'text'
   
    =head1 OPTIONS
   
    =over 4
   
    =item B<--tab>
   
    Name of the tab to (re)use. A substring is enough.
   
    =item B<--current>
   
    Use the currently focused tab.
   
    =item B<--title>
   
    Give the title of the page that is shown.
   
    =item B<--close>
   
    Automatically close the tab when the input closes. This is good
    for displaying intermediate information.
   
    =item B<--type TYPE>
   
    Force the type to be either C<html> or C<text>. If the type is
    C<text>, line wrapping will be added.
   
    =item B<--mozrepl>
   
    Connection information for the mozrepl instance to use.
   
    =back
   
    =head1 DESCRIPTION
   
    B<This program> will display HTML read from STDIN
    in a browser tab.
   
    =head1 SEE ALSO
   
    The original C<bcat> utility which inspired this program
    at L<http://rtomayko.github.com/bcat/>.
   
    =cut




example-code 5 perlscript 5


Code: Select all
        my $ff = Firefox::Application->new();
   
    # Check the network proxy settings
    my $prefs = $ff->repl->expr(<<'JS');
      Components.classes["@mozilla.org/preferences-service;1"]
        .getService(Components.interfaces.nsIPrefBranch);
    JS
   
    print "Your proxy settings are\n";
    print "Proxy type\t",  $prefs->getIntPref('network.proxy.type'),"\n";
    print "HTTP  proxy\t", $prefs->getCharPref('network.proxy.http'),"\n";
    print "HTTP  port\t",  $prefs->getIntPref('network.proxy.http_port'),"\n";
    print "SOCKS proxy\t", $prefs->getCharPref('network.proxy.socks'),"\n";
    print "SOCKS port\t",  $prefs->getIntPref('network.proxy.socks_port'),"\n";
   
    # Switch off the proxy
    if ($prefs->getIntPref('network.proxy.type') != 0) {
        $prefs->setIntPref('network.proxy.type',0);
    };
   
    # Switch on the manual proxy configuration
    $prefs->setIntPref('network.proxy.type',1);
   
   
    =head1 NAME
   
    proxy-settings.pl - display and change the proxy settings of Firefox
   
    =head1 SYNOPSIS
   
    proxy-settings.pl
   
    =head1 DESCRIPTION
   
    This shows how to read and write configuration settings
    from L<about:config> . Particularly, it shows how
    to switch the proxy settings in Firefox on and off.
   
    =cut
   



example perlscript 6 - this is a script of my own...
Code: Select all
   
    #!/usr/bin/perl
 
use WWW::Mechanize::Firefox;
use strict;
use warnings;
#use Parallel::ForkManager;
 
 
 
#my $fork = Parallel::ForkManager->new(2);
 
#sites
my @urls = qw(http://www.google.com http://www.yahoo.com http://www.cnn.com http://www.bing.com http://www.nbcnews.com/);
#temp base dir
my $temp = '/home/aaron/cgi-bin/';
 
for my $each (@urls){
   #$fork->start and next;
   my $mech = WWW::Mechanize::Firefox->new(launch => 'firefox',create => 1,);
   
   $each =~ /www\.(\w+)\.com/;
   my $name = $1;
   print "creating $name.png\n";
   
   
   $mech->get($each);
   my $png = $mech->content_as_png(undef, undef, {width => 240,height => 240});
   
   my $dir_name = "$temp/$name".".png";
   open my $file, ">", "$dir_name" or die "couldnt create $temp/$1.png";
   binmode $file;
   print {$file} $png;
   
   close $file;
   sleep 5; # sleep some to give it a little time to make sure things compleated..... you'll need this more using fork
   
   #$fork->finish;
}
print "Well All done!\n";
#$fork->wait_all_children;



Well - i think that these errors that i have shown above are somewhat different to the others that we discussed in the initlal posting.

What do you say!? I am interested to hear from you

greetings.
unleash
 
Posts: 141
Joined: 03. December 2011 10:16
Operating System: OpenSuse Linux 12.1

Return to Allerlei

Who is online

Users browsing this forum: No registered users and 4 guests