#! /usr/bin/perl # bookmarks.pl - Script to extract and print the URLs created by the Firefox # 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.txt: $!"; 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;