I used this script to allow org-web-tools to use my Firefox cookies (see this issue). The following is currently required to enable this:
(only modified parameters of call to url-retrieve-synchronously
)
(defun org-web-tools--get-url (url)
"Return content for URL as string.
This uses `url-retrieve-synchronously' to make a request with the
URL, then returns the response body. Since that function returns
the entire response, including headers, we must remove the
headers ourselves."
(let* ((response-buffer (url-retrieve-synchronously url))
(encoded-html (with-current-buffer response-buffer
;; Skip HTTP headers.
;; FIXME: Byte-compiling says that `url-http-end-of-headers' is a free
;; variable, which seems to be because it's not declared by url.el with
;; `defvar'. Yet this seems to work fine...
(delete-region (point-min) url-http-end-of-headers)
(buffer-string))))
;; NOTE: Be careful to kill the buffer, because `url' doesn't close it automatically.
(kill-buffer response-buffer)
(with-temp-buffer
;; For some reason, running `decode-coding-region' in the
;; response buffer has no effect, so we have to do it in a
;; temp buffer.
(insert encoded-html)
(condition-case nil
;; Fix undecoded text
(decode-coding-region (point-min) (point-max) 'utf-8)
(coding-system-error nil))
(buffer-string))))
(url-cookie-parse-file "~/.emacs.d/url/cookies")
Simply switch out the browser in main()
with another of the supported browsers.
Obviously calling python3 syncFirefoxCookiesToEmacs.py > ~/.emacs.d/url/cookies
overwrites your existing cookies. If you use url-cookie
with other cookies, you might consider a different approach.