Work on a version of a book including comments, is coming along swimmingly. The first version of the book I mostly copy & pasted, and formatted by hand. For this version, I've mostly automated the process. I wrote the perl script below to download the blog and strip a lot of the html formatting from the text.
#!/usr/bin/perl
use LWP::Simple;
open INFILE, "bloglinks.txt";
@lines = <INFILE>;
close INFILE;
foreach $line (@lines)
{
if ($line =~ /(http.+html)"/){unshift @urls, $1;}
}
open OF, ">blogcontent.txt";
foreach $url (@urls)
{
$on = 0;
my $content = get $url;
@content = split(/\n/, $content);
foreach $content1 (@content)
{
if ($content1 =~ /Post a Comment/){$on = 0}
if ($on == 1)
{
$content1 =~ s/<br \/>/\n/g;
$content1 =~ s/<br\/>/\n/g;
$content1 =~ s/<BR \/>/\n/g;
$content1 =~ s/<BR\/>/\n/g;
$content1 =~ s/<\/h3>/(-\/B-)/;
$content1 =~ s/<p.*?>/\n\n/g;
$content1 =~ s/<span style="font-style:italic;">/(-I-)/;
$content1 =~ s/<.*?>//g;
$content1 =~ s/.+, 200.+M/\n\n/;
$content1 =~ s/(comments:)/$1\n\n/;
$content1 =~ s/^ +$//;
$content1 =~ s/<dd class='comment-footer'>/\n\n/;
print OF $content1;
}
if ($content1 =~ /<h3 class='post-title entry-title'>/)
{
$on = 1;
print OF "(-B-)";
}
}
}
close OF;
Also, I've refamiliarized myself with
regular expressions. Regular expressions are a really powerful tool for parsing texts. I use them often when programming, but they would be really useful to anyone who had to do large scale editing and formatting of texts.
Not sure if the perl script would be of use to anyone else. If there were a demand from people who wanted to download their blog to their computer, I could probably place the script on my server and hook it up to the web to automate the process for others.
I should have a pdf of the unabridged book completed sometime next week. So far with text only, no pictures and little formatting, the book is about 300 pages. When done, I'm guessing it will be 500 some pages. If that's the case, it should cost about $20 including shipping.
So far eight copies of the book have been sold. At first I assumed that maybe grampa had bought a bunch of copies to give to friends, but additional copies of the book have been ordered. So maybe Grampa and I don't account for all the orders. If you ordered a book, thanks! Please let me know what you think of it (including any corrections/typos).
And wish the Admiral and me luck. We're running in a 5k tomorrow. I haven't run in a road race in years, but I've been working out daily at the college gym. Hopefully I'll have a good time.