gnopaste
Sorry for this ugly message. We are searching for some translators.
Please take a look here
Thanks to all translators, you're doing a great job!
Userdata
Name
Anonymous
Scriptlanguage
Plain Text
Tabwidth
4
Date
08/23/2008 01:43:01 am
IP
89.113.222.208
Description
The user was too lazy to give a description
Code (
Hide rownumbers
)
#!/usr/bin/python
import sys, httplib, re, urllib
HOST='konachan.com'
URL='/post/index.xml'
LIMIT=1000
if len( sys.argv ) < 2:
sys.stderr.write( "Usage: %s tag" % sys.argv[0] )
exit( 1 )
hc = httplib.HTTPConnection( HOST )
def fetch_index( limit, page ):
global hc
args = urllib.urlencode( { 'tags': sys.argv[1], 'limit': limit, 'page': page } )
hc.request( 'GET', URL + '?' + args )
res = hc.getresponse()
if res.status != 200:
sys.stderr.write( 'Unable to fetch index: HTTP%d' % res.status )
exit( 1 )
return res.read()
data = fetch_index( LIMIT, 1 )
# Hack since I'm too lazy to look up the doc for MatchObjects
try: count = int( re.findall( '<posts count="([0-9]+)"', data )[0] )
except:
sys.stderr.write( 'Could not locate number of posts which match this tag.' )
exit( 1 )
if count > LIMIT:
for page in range(2, count / LIMIT + 2):
data += fetch_index( LIMIT, page )
# Should parse the XML here, but fuck it use a regex instead
imgs = re.findall( 'file_url="([^"]+)"', data )
for img in imgs:
print img
submitter »
gnopaster
|
imprint
« imprint
»
Terms of use
«
Donate via
Bitcoin
:
1KCq5UvwuTMwgSAHUsd7eqkBWTHZau1ydN