View difference between Paste ID: eDqcMhND and eR9Dbiyu
SHOW: | | - or go back to the newest paste.
1-
(defun extract-next-page-number (page)
1+
(defun extract-next-page-number (stppage)
2-
  (parse-integer (let ((nexturl
2+
  (flet ((tiny-cells (stpnode)
3-
                        (stp:attribute-value (first (stp:filter-recursively
3+
                     (stp:filter-recursively
4-
                                                     #'(lambda (x) (and (typep (stp:first-child x)
4+
                      #'(lambda (x) (and (typep x 'stp:element)
5-
                                                                               'stp:text)
5+
                                         (equal (stp:local-name x) "td")
6-
                                                                        (equal (stp:data (stp:first-child x))
6+
                                         (equal (stp:attribute-value x "class") "tiny"))) stpnode))
7-
                                                                               "next >")))
7+
         (next-link (stptiny)
8-
                                                     (second
8+
                    (stp:find-recursively-if
9-
                                                      (stp:filter-recursively
9+
                     #'(lambda (x) (and (typep (stp:first-child x) 'stp:text)
10-
                                                       #'(lambda (x) (and (typep x 'stp:element)
10+
                                        (equal (stp:data (stp:first-child x)) "next >")))
11-
                                                                          (equal (stp:local-name x)
11+
                     (second stptiny)))
12-
                                                                                 "td")
12+
         (href (stphref) (stp:attribute-value stphref "href")))
13-
                                                                          (equal (stp:attribute-value x "class")
13+
        (let ((nexthref (next-link (tiny-cells stppage))))
14-
                                                                                 "tiny"))) page))))
14+
          (if (not (null nexthref))
15-
                                             "href")))
15+
              (let ((nexturl (href nexthref)))
16-
                   (subseq nexturl (1- (length nexturl))))))
16+
                (parse-integer (subseq nexturl (1- (length nexturl)))))))))