Created
November 10, 2017 19:22
-
-
Save masatoi/2251ff6c2f7d6cfdda67c2f122f8564c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ql:quickload :chirp) | |
| (in-package :chirp) | |
| ;; load key and secret | |
| (load "~/.chirp") | |
| (defun cascade-search (query &key (count 100) (interval 5) (max-cycle 100) max-id) | |
| (let ((search-result (search/tweets query :count count :max-id max-id)) | |
| (product nil)) | |
| (loop while search-result | |
| for cycle from 1 to max-cycle | |
| do | |
| (format t "cycle: ~A~%" cycle) | |
| (setf product (nconc product search-result)) | |
| (handler-case | |
| (setf search-result | |
| (search/tweets query :count count | |
| :max-id (1- (id (car (last search-result)))))) | |
| (error (e) | |
| (print e) | |
| (sleep 60))) | |
| (sleep interval)) | |
| product)) | |
| (defparameter *search-result* (cascade-search "#FGO -filter:retweets")) | |
| (defparameter *sorted-result* | |
| (sort (copy-seq *search-result*) | |
| (lambda (tw1 tw2) | |
| (> (cdr (assoc :retweets (counts tw1))) | |
| (cdr (assoc :retweets (counts tw2))))))) | |
| (defparameter *col* (collections/create "2017/11/11 #FGO")) | |
| (dolist (tw (reverse (subseq *sorted-result* 0 100))) | |
| (collections/add *col* (id tw)) | |
| (sleep 1)) | |
| (url *col*) ; => "https://twitter.com/masatoi0/timelines/929055107580248064" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment