Created
November 30, 2012 14:40
-
-
Save vladkorotnev/4176162 to your computer and use it in GitHub Desktop.
Random Gelbooru grabber
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
#!/usr/bin/env python | |
# -- CONFIG ------ | |
isMacQL = 1 # mac quicklook for the lulz | |
debugLogging = 1 # logs | |
rootUrls=["http://gelbooru.com","http://vladkorotnev.dyndns.org:8081/art","http://safebooru.org/"] | |
# ---------------- | |
try: | |
from BeautifulSoup import BeautifulSoup | |
except: | |
print "REQUIRES BEAUTIFULSOUP!" | |
import urllib | |
import subprocess | |
import random | |
rooturl = rootUrls[random.randint(0,len(rootUrls)-1)] | |
if debugLogging == 1: | |
print "gbrandom.py by vladkorotnev" | |
print "Chosen root url of "+rooturl | |
url = urllib.urlopen(rooturl+"/index.php?page=post&s=random") | |
html = url.read() | |
image = BeautifulSoup(html).findAll('img',id='image')[0]['src'] | |
urllib.urlretrieve(image,'/tmp/gbt.jpg') | |
if isMacQL == 1: | |
subprocess.call(["qlmanage","-p","/tmp/gbt.jpg"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment