Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defpackage cl-ninja.speedraker
- (:use :cl))
- (in-package :cl-ninja.speedraker)
- (defparameter *url* "https://www.speedrun.com/") ; A generic link that will be overwritten
- (defparameter *request* (dex:get *url*))
- (defparameter *parsed-content* (plump:parse *request*))
- (defparameter *outputted-content* nil)
- ;;; Functions
- (defun update-url (url)
- "Since Dexador/the web part of the program doesn't like being a placeholder
- for later use, it has to be redefined here."
- (setq *request* (dex:get url))
- (setq *parsed-content* (plump:parse *request*))
- (setq *outputted-content* (lquery:$ *parsed-content*
- "#main div div" (contents) (text))))
- (defun stats (game)
- "Downloads statistics from a given game (abbreviation)
- and puts it out to a text file"
- (let ((name (string-downcase (string game))))
- (setq *url* (format nil "https://www.speedrun.com/~a/gamestats" name))
- (update-url *url*)
- (with-open-file
- (stream (format nil "~a-stats.txt" name)
- :direction :output :if-exists :supersede
- :if-does-not-exist :create)
- (format stream "~a~%" (cl-strings:clean
- (aref *outputted-content* 3)))))) ; aref is used to convert
- ; the lquery array to a string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement