#!/usr/bin/emacs --script
(require 'dom)
(defun corona ()
(with-current-buffer (url-retrieve-synchronously "https://www.worldometers.info/coronavirus/" t)
(goto-char url-http-end-of-headers)
(setq cur-dom (libxml-parse-html-region (point) (point-max)))
(setq texts (dom-texts cur-dom))
(string-match "Coronavirus Cases: +\\([0-9,]+\\)" texts)
(setq cases (match-string 1 texts))
(string-match "Deaths: +\\([0-9,]+\\)" texts)
(setq deaths (match-string 1 texts))
(princ (format "%s / %s" deaths cases))))
(corona)
@anonymous ```
(require 'dom)
(setq corona-stats "")
(defun corona-get-stats ()
(with-current-buffer (url-retrieve-synchronously "https://www.worldometers.info/coronavirus/" t)
(goto-char url-http-end-of-headers)
(setq cur-dom (libxml-parse-html-region (point) (point-max)))
(setq texts (dom-texts cur-dom))
(string-match "Coronavirus Cases: +\([0-9,]+\)" texts)
(setq cases (match-string 1 texts))
(string-match "Deaths: +\([0-9,]+\)" texts)
(setq deaths (match-string 1 texts))
(format "👑 %s / %s" deaths cases)))
(define-minor-mode corona-mode
"Show coronavirus stats in modeline"
:global t
:lighter " 👑"
(add-to-list 'mode-line-misc-info `(corona-mode (:eval corona-stats)))
(run-with-idle-timer 0 (* 60 60) (lambda () (setq corona-stats (corona-get-stats)))))
@anonymous попробуй s/run-with-idle-timer/run-with-timer