Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Extract/Print Firefox Bookmarks HTML File

by jmlynesjr (Deacon)
on Jun 25, 2021 at 23:06 UTC ( #11134306=CUFP: print w/replies, xml ) Need Help??

Here's a script to extract and print/save the URLs exported by the Firefox Export Bookmarks to HTML function.

I know squat about HTML, but seem to have stumbled onto a good example.

A flakey laptop is the mother of invention.

#! /usr/bin/perl # bookmarks.pl - Script to extract and print the URLs created by the F +irefox # Export Bookmarks to HTML feature. # # James M. Lynes Jr. - KE4MIQ # Created: June 25, 2021 # Last Modified: 06/25/2021 - Initial version # Environment: Ubuntu 16.04 LTS # # Note: The raw HTML is very messy as it seems to include long strings # of encoded images. # Working code shamelessly stolen from the perldoc HTML::Element # example. use HTML::TreeBuilder; open(my $outfile, ">", 'bookmarks.txt') or die "Can't open bookmarks.t +xt: $!"; print $outfile "Firefox Bookmark URLs\n"; print $outfile "=====================\n"; my $tree = HTML::TreeBuilder->new(); $tree->parse_file('bookmarks.html'); for (@{ $tree->extract_links('a') }) { my($link, $element, $attr, $tag) = @$_; print "$link\n"; print $outfile "$link\n"; } $tree->delete;

James

There's never enough time to do it right, but always enough time to do it over...

Replies are listed 'Best First'.
Re: Extract/Print Firefox Bookmarks HTML File
by jdporter (Chancellor) on Jun 26, 2021 at 15:47 UTC

      Thank you for the reference. I'll take a deeper look at it this week.

      James

      There's never enough time to do it right, but always enough time to do it over...

Re: Extract/Print Firefox Bookmarks HTML File
by kaldor (Sexton) on Jul 06, 2021 at 19:07 UTC

    For next flakey laptop, or another browser, I've written a cli tool for that ;-)

    App::bookmarks

      Thanks for the feedback. Should help the next person looking for this topic.

      James

      There's never enough time to do it right, but always enough time to do it over...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://11134306]
Approved by kcott
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2022-01-28 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (73 votes). Check out past polls.

    Notices?