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 | |
by jmlynesjr (Deacon) on Jun 27, 2021 at 03:52 UTC | |
Re: Extract/Print Firefox Bookmarks HTML File
by kaldor (Beadle) on Jul 06, 2021 at 19:07 UTC | |
by jmlynesjr (Deacon) on Jul 07, 2021 at 01:39 UTC |
Back to
Cool Uses for Perl