Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

Is it possible to execute a Firefox bookmark directly using WWW::Mechanize? I know that I could just copy the url from the bookmark directly and execute it... but I'm just wondering about this.

Replies are listed 'Best First'.
Re: How to Run a FireFox Bookmark
by deMize (Monk) on Jul 06, 2010 at 19:55 UTC
    Comment: Many users are saying you can't do that with WWW::Mechanize, but I don't know why not. I think you can.

    Bookmarks are stored in an HTML file

    I just wrote and tested the following example in Windows. The paths would be different for your environment. If you're trying to load JavaScript-generated pages, then the results may be undesirable.
    #!C:\Perl\bin\ use strict; # add library path to wherever WWW::Mechanize might be use lib qw(C:\\userFoo\\myperl\\lib\\site_perl\\5.8.8); use WWW::Mechanize; my $mech = WWW::Mechanize->new(); # Create an instance of +mech my $url = 'file:///C:\Documents and Settings\userFoo\Application Data\Mozilla\Firefox\Profiles\profileBar.default\bookmarks.html'; $mech->get( $url ); # Get the bookmark file print %{$mech->follow_link( n => 11 )}; # Get and print a link's + contents



    Demize
      Actually, now Firefox stores bookmarks in a SQLite database. The bookmark manager allows the user to export to or import from either HTML or JSON, but there is no HTML or JSON file that's automatically kept up to date.

      It would require gaining familiarity with the database structure, but I assume a SQLite module could handle it fine. It's just that it's not as trivial as parsing HTML any more.

        Changing browser.bookmarks.autoExportHTML from false to true in about:config should make Firefox write a classic bookmarks.html file in parallel to the SQLite database.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: How to Run a FireFox Bookmark
by marto (Cardinal) on Jul 06, 2010 at 18:17 UTC
Re: How to Run a FireFox Bookmark
by Anonymous Monk on Jul 06, 2010 at 18:08 UTC
    What is a firefox bookmark?