※ 引述《cycle.bbs@bbs.ltcvs.ilc.edu.tw (魔流劍~劍魔流~)》之銘言:
> ※ 引述《paul.bbs@bbs.ydu.edu.tw (幸福洋溢的 paul ^^v.)》之銘言:
> > 可以到這邊下載喔! ^^~
> > 由 BioStar 分享的程式
> > http://bbs.bio.ncue.edu.tw/bbs_src/enews-open.c
> > 或是到 Maple_itoc 下載新的程式檔
> > http://home.pchome.com.tw/soho/itoc/
> 奇摩新聞是又改了嗎?!
> 又不能抓了耶....新版的程式有作修正嗎?!
作者 BioStar.bbs@micro.bio.ncue.edu.tw (澎湖小雲雀) 看板 itoc
標題 Re: 奇摩新聞
時間 吟風‧眺月‧擎天崗 (2004/05/21 Fri 03:40:51)
這樣改就可以去索取最新的新聞!
(「更多新聞」那裡的新聞比較新且多)
:util/enews-open.c:html_download()
static void
html_fetch(fpath, kind) /* 將這檔案中有效的連結找出來 */
char *fpath;
char kind; /* 種類 */
{
static int chrono = 0;
FILE *fp;
char folder[64], buf[65536];
char *start, *str1, *str2, *str3, *strA, *strB, *strC;
ENEWS enews;
int article_num;
if (!(fp = fopen(fpath, "r")))
return;
sprintf(folder, "run/kimo/%c/.ENEWS", kind);
unlink(folder); /* 重建一個新的 */
#if 0
處理 HTML 格式如下:
<a href=/040520/43/nxn9.html><big>胡錦濤重申﹁和平統一﹂政策</big></a><font c
olor=#666666><small>(中央社 2004/05/20 23:37)</small>
#endif
article_num = 0;
while (fgets(buf, 65535, fp) && !strstr(buf, "<tr><tr><td align=right valign=
top>•</td>"))
;
start = buf;
while (article_num <= 16 && strstr(start, "<a href=/"))
{
str1 = strstr(start, "<a href=/") + 9; /* 連結的起點位置 */
str2 = strstr(start, "<big>") + 5; /* 標題的起點位置 */
strA = strstr(str1, ">");
strB = strstr(str2, "</big>");
strC = strstr(str3, ")</small>");
*strA = '\0';
*strB = '\0';
*strC = '\0';
/* 加入 record */
memset(&enews, 0, sizeof(ENEWS));
enews.chrono = ++chrono; /* 每篇文章一個編號 */
enews.kind = kind;
sprintf(enews.xname, "A%06d%c", chrono, kind);
sprintf(enews.link, "http://tw.news.yahoo.com/%s", str1);
str_ncpy(enews.title, str2, sizeof(enews.title));
str_ncpy(source, str3, sizeof(source));
if (!rec_add(folder, &enews, sizeof(ENEWS)))
html_download(&enews);
article_num++;
start = strC + 1;
}
fclose(fp);
}
:util/enews-open.c:main()
int
main()
{
char kind;
char cmd[256];
char *class[12] =
{
"polity", "society", "international", "twoshore",
"finance", "entertain", "sports", "leisure",
"relaxation", "health", "technology", "odd"
};
chdir(BBSHOME)
/* 抓資料並分析之 */
for (kind = 'A'; kind <= 'L'; kind++)
{
sprintf(cmd, LYNX_PATH " 'http://tw.news.yahoo.com/more.php?newsclass=%s' >
tmp/kimo_index", class[kind - 'A']);
system(cmd);
html_fetch("tmp/kimo_index", kind);
unlink("tmp/kimo_index"); /* 清除暫存檔 */
}
return 0;
}
--
轉自 Maple_itoc 看板。 ^^~
--
我想..妳已『用妳的右手,在藍色精靈的左手裡。』 找到答案了 ^^/..
....
--
◤ ▆ `▆ ╭╯ ○ ╮-┴╯╮ ┼ ╮-┴╮ ▆ ▆ ` ◤◤ .- ' .-╲ ◣
◣◣◤◤ ╭╯-┬╯┤┴┴╭ ┼╭」四 ◣◣◤◤◣◣' .- .- ' ◣◣-◤
◣◣-◤◣-◤╰-╭│╯├ Θ │|┴ │ =|= ◣◣-◤◣-◤ 育達‧綠憶情懷 BBS ▆
◣▇▆▇╰-╮.╰|╯╯╮ο(。╮╯ 月 ╯/(乂 ▇╭-╯▇▆▇ bbs.ydu.edu.tw .◤
Author: paul 從 bbs.ydu.edu.tw 發表
討論串 (同標題文章)
完整討論串 (本文為第 5 之 7 篇):