我有几个谷歌日历,我想使用Samurize合并并放在我的Windows桌面上。我尝试过使用Samurize的Page Scraper插件,但它似乎不适合这项任务。
我可以让Samurize运行一个脚本并将其输出放在桌面上,但我不确定 什么是最好的工具来做到这一点。
我拥有的所有网址都是以下形式:
http://www.google.com/calendar/feeds/example%40gmail.com/private-REMOVED/basic?futureevents=true&orderby=starttime&sortorder=ascending&singleevents=true
所以我可以使用curl来获取它们,但之后我需要过滤它们。
我想要的东西看起来像:
2009 12 02 Event from calendar 1's description
2009 12 03 Event from calendar 2's description
2009 12 04 Event from calendar 1's description
2009 12 05 Event from calendar 3's description
2009 12 06 Event from calendar 1's description
但是,日历Feed中的日期格式如下:
<title type='html'>Event from calendar 1's description</title><summary type='html'>When: Fri 5 Dec 2008<br>
那么如何过滤日期和说明,并转换日期?
(我安装了cygwin,所以使用perl或sed / awk的东西会很完美,因为我对他们很熟悉,以后我会有信心改变它们,但我愿意接受建议。)
答案 0 :(得分:1)
我正在学习perl所以请不要笑得太厉害,但这里有一些东西可以帮助你解决大部分问题:
#!C:\Perl\bin -w
use strict;
my %months = ("Jan", "01", "Feb", "02", "Mar", "03", ... etc. etc. ... "Dec", "12");
$_ = "<title type='html'>Event from calendar 1's description</title><summary type='html'>When: Fri 5 Dec 2008<br>";
if (/<title type='html'>([\d\D]*)<\/title><summary type='html'>When: (\S+) (\S+) (\S+) (\S+)<br>/)
{
print "$5 $months{$4} $3 $1\n";
}
答案 1 :(得分:1)
以John W的脚本为基础,这就是我正在使用的
#!c:\cygwin\bin\perl.exe -w
use strict;
use LWP::Simple qw(get);
my %calendars = ( "Sam Hasler", "http://www.google.com/calendar/feeds/blah/blah/basic"
, "Family ", "http://www.google.com/calendar/feeds/blah/blah/basic"
, "Work ", "http://www.google.com/calendar/feeds/blah/blah/basic"
);
my $params = "?futureevents=true&orderby=starttime&sortorder=ascending&singleevents=true";
my %months = ( "Jan", "01", "Feb", "02", "Mar", "03", "Apr", "04"
, "May", "05", "Jun", "06", "Jul", "07", "Aug", "08"
, "Sep", "09", "Oct", "10", "Nov", "11", "Dec", "12");
my $calendar_name;
my $calendar_url;
my @lines;
while (($calendar_name, $calendar_url) = each(%calendars)){
my $calendar_data = get "$calendar_url$params";
@lines = split(/\n/, $calendar_data);
foreach (@lines) {
if (/<title type='html'>([\d\D]*)<\/title><summary type='html'>When: (\S+) (\S+) (\S+) (\S+)<br>/)
{
my $day = "$3";
if ($3 < 10 ) {
$day = "0$3";
}
print "$5 $months{$4} $day\t$calendar_name\t$1\n";
}
}
}
我只是通过sort
管道输出以按日期顺序获取它。
更新:我已将脚本转换为插件并将其提交至Samurize网站:Merge Google Calendar feeds。
答案 2 :(得分:1)