html转换农历.pl

软件和网站开发以及相关技术探讨
回复
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

html转换农历.pl

#1

帖子 eexpress » 2010-02-20 20:11

代码: 全选

● wget http://www.herongyang.com/2010/2010_chinese_calendar_gb.html -o 2010年年历.html

● cat html转换农历.pl 
#!/usr/bin/perl
use Encode;
#http://www.herongyang.com/2010/2010_chinese_calendar_gb.html
print "#ifndef _calendar_lunar\n#define _calendar_lunar\n\nLANG=utf-8\n\n";

open (HTML,$ARGV[0])||die "没有找到农历html文件。";
@l=<HTML>; close HTML;

@l=map m:(<td.*?\d.*?/td>):,@l;
map {s/<br\/>/_/g;s/<.*?>//g;push @l;} @l;
foreach(<@l>){
        chomp;
        if(! /_/){$month=$_;}
        else{s/_/\t/g;
        $_=decode("GBK", $_);$_=encode("UTF-8", $_);
        print "$month/$_\n";}
}
print "\n#endif\n";

● ./html转换农历.pl 2010年年历.html >~/.calendar/calendar.2010.lunar

● calendar -A 15 -f ~/.calendar/calendar.2010.lunar 
 2月 20         初七
 2月 21         初八
 2月 22         初九
 2月 23         初十
 2月 24         十一
 2月 25         十二
 2月 26         十三
 2月 27         十四
 2月 28         十五
 3月 01         十六
 3月 02         十七
 3月 03         十八
 3月 04         十九
 3月 05         二十
 3月 06         惊蛰
 3月 07         廿二
● 鸣学
头像
tenzu
论坛版主
帖子: 36924
注册时间: 2008-11-21 20:26

Re: html转换农历.pl

#2

帖子 tenzu » 2010-02-20 20:39

前排马克 :em70
JiangHui
论坛版主
帖子: 21308
注册时间: 2007-08-02 20:29
系统: 窓辺とうこ

Re: html转换农历.pl

#3

帖子 JiangHui » 2010-02-20 21:27

:em70
头像
ChenFengyuan
帖子: 770
注册时间: 2008-03-23 0:39

Re: html转换农历.pl

#4

帖子 ChenFengyuan » 2010-02-21 13:54

:em06
wget xxxxx -o 2010xxxx,
应该是-O 2010xxxx吧
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: html转换农历.pl

#5

帖子 eexpress » 2010-12-16 14:27

代码: 全选

● cd ~/bin/calendar.ics.转换
● wget http://www.herongyang.com/2011/2011_chinese_calendar_gb.html -O 2011年年历.html
● ./html转换农历.pl 2011年年历.html > ~/.calendar/calendar.2011.lunar
● wget http://www.herongyang.com/2012/2012_chinese_calendar_gb.html -O 2012年年历.html
● ./html转换农历.pl 2012年年历.html > ~/.calendar/calendar.2012.lunar
● wget http://www.herongyang.com/2013/2013_chinese_calendar_gb.html -O 2013年年历.html
● ./html转换农历.pl 2013年年历.html > ~/.calendar/calendar.2013.lunar
● cd ~/.calendar
● l
calendar             calendar.2012.lunar  calendar.china.gg
calendar.2010.lunar  calendar.2013.lunar  calendar.eexp
calendar.2011.lunar  calendar.china
● 鸣学
头像
leeaman
帖子: 30702
注册时间: 2007-02-02 18:14
系统: debian sid

Re: html转换农历.pl

#6

帖子 leeaman » 2010-12-16 16:14

嗯,还可以,这个直接可以执行了,calendar.eexp估计是记录ee生日啦,二奶第一次约会纪念之类的,不给我 :em04
醉了星星,醉月亮●●●●●The Long Way To Go(*^_^*)
头像
leeaman
帖子: 30702
注册时间: 2007-02-02 18:14
系统: debian sid

Re: html转换农历.pl

#7

帖子 leeaman » 2010-12-16 16:16

麻烦更新一下calendar.china,然后发上来 :em05
醉了星星,醉月亮●●●●●The Long Way To Go(*^_^*)
himandy
帖子: 100
注册时间: 2008-11-09 13:43

Re: html转换农历.pl

#8

帖子 himandy » 2010-12-26 19:27

./html转换农历.pl 2011年年历.html > ~/.calendar/calendar.2011.lunar

执行这一句时,显示错误:
-bash: ./html转换农历.pl: 没有那个文件或目录

我已经复制了楼主提供的代码,把这个perl文件放在主文件夹了,设了可执行权限。请问是什么原因导致的?
头像
leeaman
帖子: 30702
注册时间: 2007-02-02 18:14
系统: debian sid

Re: html转换农历.pl

#9

帖子 leeaman » 2010-12-26 19:42

你保存的是什么名字啊?*.pl,那个*是自己随便取名字的啦,还有你放那里,是不是在当前目录下面
醉了星星,醉月亮●●●●●The Long Way To Go(*^_^*)
himandy
帖子: 100
注册时间: 2008-11-09 13:43

Re: html转换农历.pl

#10

帖子 himandy » 2010-12-26 20:00

成功了,原来我在填写文件名“html.转换农历.pl”的时候在后面多复制了一个空格……
回复