Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

WWW::Mechanize work-alike for Common Lisp

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .gitignore
Octocat-spinner-32 COPYING
Octocat-spinner-32 README.md
Octocat-spinner-32 cl-mechanize.asd
Octocat-spinner-32 cl-mechanize.lisp
Octocat-spinner-32 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.