http://qs321.pair.com?node_id=11134306

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 (Paladin) 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 (Beadle) 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...