トップ «前の日記(2007-02-28 (Wed)) 最新 次の日記(2007-03-08 (Thu))» 編集

猫熊は燃えつきた?!日記

最近なんにもやっていませんが、なにかやったらこちらに置くようにしています。
2002|12|
2003|01|02|03|04|05|06|07|08|09|10|11|12|
2004|01|02|03|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|
2011|09|
2012|02|


2007-03-01 (Thu) [長年日記]

お返事

いや、やっぱり Firefox の方が 8192倍すごいと。。。

そのほかの w3m-filter 関連

調子にのって、以前から使っている『読売、産経、朝日三紙の記事本文を読みやすくする』という filter も出しちゃいます。
shimbun.el に導入された shimbun-japanese-hankaku-buffer() も本日から導入してみた。
(add-hook 'w3m-mode-hook
	  (lambda ()
	    (define-key w3m-mode-map "\M-k" 'w3m-shimbun-noextract)
	    (define-key w3m-mode-map "\M-K" 'w3m-cookie)))
  
(setq w3m-use-filter t)
  
(setq w3m-filter-rules
      `( ;; ....
 	("\\`http://www.?\\.yomiuri\\.co\\.jp/" w3m-filter-yomiuri-kiji)
	("\\`http://www.?\\.sankei\\.co\\.jp/" w3m-filter-sankei-kiji)
 	("\\`http://www.?\\.asahi\\.com/" w3m-filter-asahi-kiji)))
  
(defun w3m-shimbun-noextract ()
  (interactive)
  (if (not (and w3m-current-url
		(or
		 (string-match "\\`http://[^.]+\\.asahi\\.com/" w3m-current-url)
		 (string-match "\\`http://[^.]+\\.sankei\\.co\\.jp/" w3m-current-url)
		 (string-match "\\`http://[^.]+\\.yomiuri\\.co\\.jp/" w3m-current-url))))
      (message "読売新聞/産経新聞/朝日新聞だけよ")
    (w3m-redisplay-this-page)))
  
(defun w3m-filter-yomiuri-kiji (url)
  (when (and (or (featurep 'shimbun) (require 'shimbun))
	     (fboundp 'shimbun-japanese-hankaku-buffer))
    (shimbun-japanese-hankaku-buffer t))
  (unless (eq this-command 'w3m-shimbun-noextract)
    (let (start end)
      (goto-char (point-min))
      (when (search-forward "</head>" nil t)
	(setq start (match-end 0))
	(when (search-forward "<!--// headline_start //-->" nil t)
	  (delete-region start (match-beginning 0))
	  (when (search-forward "<!--// article_end //-->" nil t)
	    (setq start (match-end 0))
	    (when (search-forward "</body>" nil t)
	      (delete-region start (match-beginning 0))
	      (when (search-forward "</html>" nil t)
		(delete-region (match-end 0) (point-max))))))))))
  
(defun w3m-filter-sankei-kiji (url)
  (when (and (or (featurep 'shimbun) (require 'shimbun))
	     (fboundp 'shimbun-japanese-hankaku-buffer))
    (shimbun-japanese-hankaku-buffer t))
  (unless (eq this-command 'w3m-shimbun-noextract)
    (let (start end)
      (goto-char (point-min))
      (when (search-forward "<body>" nil t)
	(setq start (match-end 0))
	(when (search-forward "<!--▼記事本文▼-->" nil t)
	  (delete-region start (match-beginning 0))
	  (when (search-forward "<!--▲記事本文▲-->" nil t)
	    (setq start (match-end 0))
	    (when (search-forward "</body>" nil t)
	      (delete-region start (match-beginning 0))
	      (when (search-forward "</html>" nil t)
		(delete-region (match-end 0) (point-max))))))))))
  
(defun w3m-filter-asahi-kiji (url)
  (when w3m-use-mule-ucs
    (goto-char (point-min))
    (let ((case-fold-search t)
	  end ucs)
      (while (re-search-forward "alt=\"\\([^\"]+\\)" nil t)
	(goto-char (match-beginning 1))
	(setq end (set-marker (make-marker) (match-end 1)))
	(while (re-search-forward "&#\\([0-9]+\\);" (max end (point)) t)
	  (setq ucs (string-to-number (match-string 1)))
	  (delete-region (match-beginning 0) (match-end 0))
	  (insert-char (w3m-ucs-to-char ucs) 1)))))
  (when (and (or (featurep 'shimbun) (require 'shimbun))
	     (fboundp 'shimbun-japanese-hankaku-buffer))
    (shimbun-japanese-hankaku-buffer t))
  (unless (eq this-command 'w3m-shimbun-noextract)
    (let (start end)
      (goto-char (point-min))
      (when (search-forward "</head>" nil t)
	(setq start (match-end 0))
	(when (or (search-forward "<h1 class=\"kijimidashi\">" nil t)
		  (search-forward "<!-- Start of Headline -->" nil t)
		  (search-forward "<!-- Start of photo -->" nil t)
		  (search-forward "<!-- Start of Kiji -->" nil t))
	  (delete-region start (match-beginning 0))
	  (when (or (search-forward "<!-- google_ad_section_end" nil t)
		    (search-forward "<div class=\"clear\">" nil t)
		    (search-forward "<div class=\"pr\">" nil t)
		    (search-forward "<div class=\"list\">" nil t))
	    (setq start (match-beginning 0))
	    (when (search-forward "</body>" nil t)
	      (delete-region start (match-beginning 0)))
	    (goto-char (point-min))
	    (while (re-search-forward "<table [^>]+>" nil t)
	      (delete-region (match-beginning 0) (match-end 0)))
	    (goto-char (point-min))
	    (while (search-forward "</table>" nil t)
	      (delete-region (match-beginning 0) (match-end 0)))))))))
本文だけになった記事の全部をみたいときは、M-k を押す。もともと M-k だった w3m-cookie() は M-K へ移動
動けば良いやのレベルなので、綺麗さや速度は考えていないし、HTML の構造が変わると動かなくなるが、悪さをすることも無いでしょう。

書いている人: 白井秀行 (mailto:shirai@meadowy。org)
訪問して下さった人: 今日: 人, 昨日: , 過去: 人 (2007年5月10日から)
RDF Feed