Skip to content

Instantly share code, notes, and snippets.

@miyamuko
Created January 17, 2012 02:35
Show Gist options
  • Save miyamuko/1624211 to your computer and use it in GitHub Desktop.
Save miyamuko/1624211 to your computer and use it in GitHub Desktop.
HTML を txt 形式に変換して取得 #xyzzy
(defun response-html-text (res)
(filter-command "w3m -I Shift_JIS -T text/html"
(xhr:xhr-response-text res)
:environ '(("LANG" . "ja_JP"))))
(defun filter-command (command str &key tmp-file-prefix tmp-file-suffix
environ exec-directory)
(let ((in-file (make-temp-file-name tmp-file-prefix tmp-file-suffix))
(out-file (make-temp-file-name tmp-file-prefix tmp-file-suffix)))
(unwind-protect
(progn
(alexandria:write-string-into-file str in-file :if-exists :overwrite)
(call-process command
:input in-file
:output out-file
:environ environ
:exec-directory exec-directory
:show :hide :wait t
)
(alexandria:read-file-into-string out-file))
(flet ((del (file)
(delete-file file :if-does-not-exist :skip)))
(del in-file)
(del out-file)))))
(xhr:xhr-get "http://www.hatena.ne.jp/"
:key 'response-html-text)
"はてな
・ ●プロフィール
・ Myはてな
・ プロフィール検索
・ ヘルプ
・ 利用中のサービス
・ あなたへのお知らせ
(ry
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment