Skip to content
WWW::Mechanize work-alike for Common Lisp
Common Lisp
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore Add .gitignore
COPYING Bump copyright year
README.md README: a stronger warning about the usability of this package
cl-mechanize.asd Initial commit
cl-mechanize.lisp Add configuration variables for controlling cookies
packages.lisp

README.md

About

CL-MECHANIZE is a WWW::Mechanize work-alike for Common Lisp implemented as a thin wrapper on top of Drakma.

This package is still in the early stages of development. Please read the source before using; do not expect this to do anything useful.

Getting

git clone git://github.com/joachifm/cl-mechanize.git cl-mechanize

Use QuickLisp to easily install the dependencies.

Usage

$ lisp

;; Add system definition to the ASDF search path
(pushnew (merge-pathnames "relative/path/to/cl-mechanize"
                          (user-homedir-pathname))
         asdf:*central-registry*)

;; Load system
(asdf:operate 'asdf:load-op :cl-mechanize)
(in-package :cl-mechanize-user)

;; Create browser object
(defvar *browser* (make-instance 'browser)

;; Do a google search
(fetch "http://www.google.com" *browser*)

(let* ((page (browser-page *browser*))
       (search-form (car (page-forms page))))
  (setf (form-inputs search-form)
        '(("q" . "google")))
  (submit search-form *browser*)

  (let ((results (browser-page *browser*)))
    (format t "~A~%" (ppcre:all-matches-as-strings "<title>[a-z].*</title>"
                                                 (page-content results)))
    (dolist (link (page-links results))
      (format t "~A~%" (link-text link)))

    ;; Traverse the DOM
    (stp:do-recursively (n (page-dom results))
        ...)))
Something went wrong with that request. Please try again.