Skip to content

Instantly share code, notes, and snippets.

@ary15
Created March 23, 2018 09:41
Show Gist options
  • Save ary15/9981de57132fa7f70e33f873c206648a to your computer and use it in GitHub Desktop.
Save ary15/9981de57132fa7f70e33f873c206648a to your computer and use it in GitHub Desktop.
Modifying science direct download
;;** Science Direct
(defun doi-utils-get-science-direct-pdf-url (redirect-url)
"Science direct hides the pdf url in html. We get it out here.
REDIRECT-URL is where the pdf url will be in."
(setq *doi-utils-waiting* t)
(url-retrieve
redirect-url
(lambda (status)
(goto-char (point-min))
(re-search-forward "pdf_url\" content=\"\\([^\"]*\\)\"" nil t) ; modified the search string to reflect updated science direct
(setq *doi-utils-pdf-url* (match-string 1)
*doi-utils-waiting* nil)))
(while *doi-utils-waiting* (sleep-for 0.1))
*doi-utils-pdf-url*)
(defun linkinghub-elsevier-pdf-url (*doi-utils-redirect*)
"Get url to the pdf from *DOI-UTILS-REDIRECT*."
(when (string-match
"^https://linkinghub.elsevier.com/retrieve" *doi-utils-redirect*)
;; (let ((second-redirect ; second redirect isn't necessary
(doi-utils-get-science-direct-pdf-url (replace-regexp-in-string ; change URL to science direct and use function to get pdf URL
"https://linkinghub.elsevier.com/retrieve"
"https://www.sciencedirect.com/science/article"
*doi-utils-redirect*))
*doi-utils-pdf-url*))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment