Skip to content

Instantly share code, notes, and snippets.

@kototama
Created November 3, 2023 20:46
Show Gist options
  • Save kototama/5386d1ff2203451c443776e7861f4f9a to your computer and use it in GitHub Desktop.
Save kototama/5386d1ff2203451c443776e7861f4f9a to your computer and use it in GitHub Desktop.
Scrapping a page with Common Lisp
;; see https://github.com/TatriX/cl-selenium-webdriver
(defpackage scrapov
(:use :cl :cl-selenium ))
(in-package :scrapov)
(defparameter *code* "
package main
import \"fmt\"
func main() {
fmt.Print(\"Hello WebDriver!\")
}")
(with-session ()
(setf (url) "http://play.golang.org/?simple=1")
(let ((elem (find-element "#code" :by :css-selector)))
(element-clear elem)
(element-send-keys elem *code*))
(let ((btn (find-element "#run")))
(element-click btn))
(cl-selenium-utils:wait-for ".Playground-output .system")
(loop
with div = (find-element ".Playground-output .system")
for ouput = (element-text div)
while (equal ouput "Waiting for remote server...")
do (sleep 0.1)
finally (let ((result (element-text (find-element ".Playground-output .stdout"))))
(print result))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment