aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/lisp/my/my-wget.el
diff options
context:
space:
mode:
Diffstat (limited to 'emacs/.emacs.d/lisp/my/my-wget.el')
-rw-r--r--emacs/.emacs.d/lisp/my/my-wget.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-wget.el b/emacs/.emacs.d/lisp/my/my-wget.el
index a55bb12..f3f6771 100644
--- a/emacs/.emacs.d/lisp/my/my-wget.el
+++ b/emacs/.emacs.d/lisp/my/my-wget.el
@@ -30,6 +30,7 @@
;; wget
(require 'wget)
(require 'my-utils)
+(require 'tor)
(defvar my-wget-video-archive-directory)
;; FIXME: this list is rather random...
(setq my-wget-video-extensions '("mp4" "flv" "mkv" "webm" "ogv" "avi"
@@ -85,5 +86,22 @@
no-tor move-if-video-or-large)
(setq i (1+ i)))))
+(defun my-wget-out-internal (url buffer-processor &optional no-tor)
+ "Run wget on url, dump the results in a temp buffer, then apply BUFFER-PROCESSOR"
+ (with-temp-buffer
+ (my-call-process-with-torsocks no-tor "wget" nil '(t nil) nil "-O" "-" url)
+ (call-interactively 'delete-trailing-whitespace)
+ (funcall buffer-processor)
+ ))
+
+(defun my-wget-dom (url &optional no-tor)
+ (my-wget-out-internal
+ url
+ (lambda () (libxml-parse-html-region (point-min) (point-max)))
+ no-tor))
+
+(defun my-wget-raw (url &optional no-tor)
+ (my-wget-out-internal url 'buffer-string no-tor))
+
(provide 'my-wget)
;;; my-wget.el ends here