bairui

A Google Hits Counter in newLISP

Jul 19th, 2011
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/newlisp
  2.  
  3. # gcount - google count
  4. # (code taken from the www.newlisp.org website)
  5.  
  6. (set 'pattern "(?i)about\\s*([\\d,]+)\\s*results")
  7.  
  8. (define (hits str)
  9.   (regex pattern (get-url
  10.                    (string "http://www.google.com/search?hl=en&q=" (replace " " str "+"))))
  11.   (string $1))
  12.  
  13. (dolist (str (2 (main-args)))
  14.   (println (format "%s -> %s" str (set 'hts (hits str))))
  15.   (push (int (replace "," hts "")) lst))
  16.  
  17. (if (= (length lst) 2)
  18.   (println (format "ratio: %.2f:1" (div (lst 1) (lst 0)))))
  19.  
  20. (exit)
Add Comment
Please, Sign In to add comment