sf2slash
#!perl -w
use strict;
use LWP::Simple;
use Slash::DB;
use Slash::Utility;
createEnvironment('useperl');
my $url = 'http://sourceforge.net/developer/diary.php?diary_user=3660&diary_id=';
my @ids = qw(2477 2418 2356 2312 2261 2244 2152 2126 2082 1952 1936
1857 1848 1777 1753 1738 1724 1643 1637 1542 1536 1527 1488
1461 1427 1394 1384 1318 1297 1282 1272);
my $slashdb = getCurrentDB();
for (@ids) {
my($date, $subj, $body);
$_ = get($url . $_);
s/\015//g;
m|<TD colspan=2><TR><TD COLSPAN=2><B>Date:</B> (.+?)<BR>|s;
$date = $1;
m|<B>Subject:</B> (.+?)<P>|s;
$subj = $1;
m|<B>Body:</B><BR>(.+?)</TD></TR>|s;
($body = $1) =~ s/<br>\n<br>\n/\n\n/g;
$body =~ s/<br>\n//g;
for ($date, $subj, $body) {
s/^\s+//;
s/\s+$//;
}
$slashdb->sqlInsert('journals', {
uid => 1,
description => $subj,
date => $date,
posttype => 1,
});
my($id) = $slashdb->sqlSelect('LAST_INSERT_ID()');
$slashdb->sqlInsert('journals_text', {
id => $id,
article => strip_plaintext($body),
});
print "Inserted $id\n";
}
__END__
use strict;
use LWP::Simple;
use Slash::DB;
use Slash::Utility;
createEnvironment('useperl');
my $url = 'http://sourceforge.net/developer/diary.php?diary_user=3660&diary_id=';
my @ids = qw(2477 2418 2356 2312 2261 2244 2152 2126 2082 1952 1936
1857 1848 1777 1753 1738 1724 1643 1637 1542 1536 1527 1488
1461 1427 1394 1384 1318 1297 1282 1272);
my $slashdb = getCurrentDB();
for (@ids) {
my($date, $subj, $body);
$_ = get($url . $_);
s/\015//g;
m|<TD colspan=2><TR><TD COLSPAN=2><B>Date:</B> (.+?)<BR>|s;
$date = $1;
m|<B>Subject:</B> (.+?)<P>|s;
$subj = $1;
m|<B>Body:</B><BR>(.+?)</TD></TR>|s;
($body = $1) =~ s/<br>\n<br>\n/\n\n/g;
$body =~ s/<br>\n//g;
for ($date, $subj, $body) {
s/^\s+//;
s/\s+$//;
}
$slashdb->sqlInsert('journals', {
uid => 1,
description => $subj,
date => $date,
posttype => 1,
});
my($id) = $slashdb->sqlSelect('LAST_INSERT_ID()');
$slashdb->sqlInsert('journals_text', {
id => $id,
article => strip_plaintext($body),
});
print "Inserted $id\n";
}
__END__
Leave a comment