Oladon

extract-next-page-number (2)

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