Scraper para DEV desde Emacs
Yoandy Rodriguez Martinez

Yoandy Rodriguez Martinez @yorodm

About: Desarrollo, leo y blogueo acerca de software, soy seguidor de Linux, Python , Go y todo lo que huela a Common-Lisp

Location:
Sofia, Bulgaria
Joined:
Mar 10, 2018

Scraper para DEV desde Emacs

Publish Date: Nov 21 '18
6 2

Scrapper para DEV desde Emacs.

Recién publiqué en DEV un artículo acerca de como hacer un scraper para obtener los títulos del feed principal. El artículo surgió de una discusión amistosa acerca de la relevancia de Common Lisp como tecnología en la actualidad y quedé muy satisfecho con el resultado.

Me llamó tanto la atención la simpleza detrás de las bibliotecas utilizadas que decidí ver si había una para Emacs Lisp y… TL;DR, aquí está el scrapper 😍.

;;; Eval this in the scratch buffer, first make sure to get
;;; `elquery' from MELPA.
;;; Eval this in a buffer and get the headlines in *another* buffer
;;; named *dev*
(require 'elquery)
(let ((dev-buffer (generate-new-buffer "*dev*")))
  (with-current-buffer (url-retrieve-synchronously "https://dev.to")
    ;; Feel free to hate this
    (dolist (elt (mapcar 'elquery-text (elquery-$ "div.single-article h3"
                                                  (elquery-read-string (buffer-string)))))
      (with-current-buffer dev-buffer (insert (concat elt "\n"))))))
Enter fullscreen mode Exit fullscreen mode

Comments 2 total

Add comment