Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; This one's cool because it finds the correct element based on its parent's parent.
- (defun get-title-from-page (page)
- (stp:data
- (car (last (stp:filter-recursively
- #'(lambda (x) (and (typep x 'stp:text)
- (stp:attribute-value (stp:parent x) "title")
- (equal (stp:attribute-value (stp:parent (stp:parent x)) "class")
- "browseLadderCurrentNode")))
- page)))))
- (defun page-iterate (iterfunc url)
- (let* ((threadbase (ppcre:regex-replace "\\?[^&]+"
- (ppcre:regex-replace "&page=(last|first|[0-9]+)"
- url
- "")
- ""))
- (page (get-parsed-page (make-new-url threadbase '(("page" . 1)) :paizo t)))
- (title (get-title-from-page page)))
- (values title
- (loop as nextpage = (extract-next-page-number page)
- append (funcall iterfunc page)
- while nextpage
- do (setq page (get-parsed-page (make-new-url threadbase
- (list (cons "page" nextpage))
- :paizo t)))))))
Advertisement
Add Comment
Please, Sign In to add comment