Last update: 2023-11-19

URLからDOMを得る   Emacs EmacsLisp

Emacs Lispを使ってDOMを操作する方法。

(with-current-buffer
    (url-retrieve-synchronously "https://example.com")
  (let* ((dom (libxml-parse-html-region url-http-end-of-headers (point-max)))
         (tag-title (dom-by-tag dom 'title))
         (title (dom-text tag-title)))
    title))
"Example Domain"