Oladon

extract-next-page-number

Nov 8th, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.27 KB | None | 0 0
  1. (defun extract-next-page-number (page)
  2.   (parse-integer (let ((nexturl
  3.                         (stp:attribute-value (first (stp:filter-recursively
  4.                                                      #'(lambda (x) (and (typep (stp:first-child x)
  5.                                                                                'stp:text)
  6.                                                                         (equal (stp:data (stp:first-child x))
  7.                                                                                "next >")))
  8.                                                      (second
  9.                                                       (stp:filter-recursively
  10.                                                        #'(lambda (x) (and (typep x 'stp:element)
  11.                                                                           (equal (stp:local-name x)
  12.                                                                                  "td")
  13.                                                                           (equal (stp:attribute-value x "class")
  14.                                                                                  "tiny"))) page))))
  15.                                              "href")))
  16.                    (subseq nexturl (1- (length nexturl))))))
Advertisement
Add Comment
Please, Sign In to add comment