Adding lfgimg written in CL
This commit is contained in:
		
							parent
							
								
									db31255bc8
								
							
						
					
					
						commit
						b0cb73adda
					
				
					 1 changed files with 30 additions and 0 deletions
				
			
		
							
								
								
									
										30
									
								
								scripts/lfgimg.lisp
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										30
									
								
								scripts/lfgimg.lisp
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,30 @@
 | 
			
		|||
#!/usr/bin/sbcl --script
 | 
			
		||||
 | 
			
		||||
(load "~/quicklisp/setup.lisp")
 | 
			
		||||
(ql:quickload '(drakma lquery))
 | 
			
		||||
 | 
			
		||||
(defun get-images ()
 | 
			
		||||
  (loop for i from 748 to 1489 do
 | 
			
		||||
    (let* ((request (drakma:http-request
 | 
			
		||||
		     (concatenate 'string "https://www.lfg.co/page/" (write-to-string i))))
 | 
			
		||||
	   (parsed-content (lquery:$ (lquery:initialize request)))
 | 
			
		||||
	   (url (vector-pop (lquery:$ parsed-content "img" (attr :src))))
 | 
			
		||||
	   (img (drakma:http-request url)))
 | 
			
		||||
 | 
			
		||||
      (if (not (search ".jpg" url))
 | 
			
		||||
	  (with-open-file (stream
 | 
			
		||||
			   (concatenate 'string "/home/chris/Pictures/lfg/" (write-to-string i) ".gif")
 | 
			
		||||
			   :direction :output
 | 
			
		||||
			   :if-exists :supersede
 | 
			
		||||
			   :if-does-not-exist :create
 | 
			
		||||
			   :element-type 'unsigned-byte)
 | 
			
		||||
	    (write-sequence img stream))
 | 
			
		||||
	  (with-open-file (stream
 | 
			
		||||
			   (concatenate 'string "/home/chris/Pictures/lfg/" (write-to-string i) ".jpg")
 | 
			
		||||
			   :direction :output
 | 
			
		||||
			   :if-exists :supersede
 | 
			
		||||
			   :if-does-not-exist :create
 | 
			
		||||
			   :element-type 'unsigned-byte)
 | 
			
		||||
	    (write-sequence img stream))))))
 | 
			
		||||
 | 
			
		||||
(get-images)
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue