* sb-asahi.el: Follow the page renewal.
[elisp/wanderlust.git] / elmo / sb-zdnet.el
1 ;;; sb-zdnet.el --- shimbun backend for Zdnet Japan
2
3 ;; Author: TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>
4 ;;         Akihiro Arisawa    <ari@atesoft.advantest.co.jp>
5 ;;         Yuuichi Teranishi <teranisi@gohome.org>
6
7 ;; Keywords: news
8
9 ;;; Copyright:
10
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, you can either send email to this
23 ;; program's maintainer or write to: The Free Software Foundation,
24 ;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;; Original code was nnshimbun.el written by
29 ;; TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>.
30
31 ;;; Code:
32
33 (require 'shimbun)
34 (luna-define-class shimbun-zdnet (shimbun) ())
35
36 (defvar shimbun-zdnet-url "http://www.zdnet.co.jp/news/")
37 (defvar shimbun-zdnet-groups '("comp"))
38 (defvar shimbun-zdnet-coding-system (static-if (boundp 'MULE)
39                                         '*sjis* 'shift_jis))
40 (defvar shimbun-zdnet-from-address "zdnn@softbank.co.jp")
41 (defvar shimbun-zdnet-content-start "\\(<!--BODY-->\\|<!--DATE-->\\)")
42 (defvar shimbun-zdnet-content-end "\\(<!--BODYEND-->\\|<!--BYLINEEND-->\\)")
43
44 (luna-define-method shimbun-get-headers ((shimbun shimbun-zdnet))
45   (let ((case-fold-search t) headers)
46     (goto-char (point-min))
47     (let (start)
48       (while (and (search-forward "<!--" nil t)
49                   (setq start (- (point) 4))
50                   (search-forward "-->" nil t))
51         (delete-region start (point))))
52     (goto-char (point-min))
53     (while (re-search-forward
54             "<a href=\"\\(/news/\\)?\\(\\([0-9][0-9]\\)\\([0-9][0-9]\\)/\\([0-9][0-9]\\)/\\([^\\.]+\\).html\\)\"><font size=\"4\"><strong>"
55             nil t)
56       (let ((year  (+ 2000 (string-to-number (match-string 3))))
57             (month (string-to-number (match-string 4)))
58             (day   (string-to-number (match-string 5)))
59             (id    (format "<%s%s%s%s%%%s>"
60                            (match-string 3)
61                            (match-string 4)
62                            (match-string 5)
63                            (match-string 6)
64                            (shimbun-current-group-internal shimbun)))
65             (url (match-string 2)))
66         (push (shimbun-make-header
67                0
68                (shimbun-mime-encode-string
69                 (mapconcat 'identity
70                            (split-string
71                             (buffer-substring
72                              (match-end 0)
73                              (progn (search-forward "</a>" nil t) (point)))
74                             "<[^>]+>")
75                            ""))
76                (shimbun-from-address-internal shimbun)
77                (shimbun-make-date-string year month day)
78                id  "" 0 0 (concat (shimbun-url-internal shimbun) url))
79               headers)))
80     (nreverse headers)))
81
82 (provide 'sb-zdnet)
83
84 ;;; sb-zdnet.el ends here