File :-(, x, )
KonaChan grabber Anonymous
repost from /a/

http://pastebin.com/m4f885a0e
The grabber of konachan. Written in Python.
Usage is simply: creating a file, making it executable (chmod +x), then executing it with some tag of Konachan. It will generate the links list. All the links to the images with the tag you used in stdout.
usage to download is just like that: konachan some_tag| xargs wget

================================

Also, you can use it in Windows.
Just cd (in cmd.exe) to dir with this script, then type:

python konachan.py lucky_star > links.txt

(lucky_star is tag for example, konachan.py is this script)
Comment too long. Clickhereto view the full text.
>> Anonymous
Why would anyone put their python binary in a place other than /usr/local/bin?
>> Anonymous
I think that it is not really difficult to change this line.
>> Anonymous
yay asuka
>> Anonymous
Why the hell are you parsing the index?
Pull the image listing from http://konachan.com/post/index.xml

There's a whole damn API for this kind of thing http://konachan.com/help/api
>> Anonymous
Because this is just a simple tag grabber.

btw thanks for links.
>> Anonymous
>>514692
you can parse the json instead, should be easier in some cases
http://konachan.com/post/index.json
>> Anonymous
For people wanting al the content I'll just update the torrent I did at the beginning of this year.
http://www.fapis.com/entry.html?id=10914

Maybe at the end of August or so. Not sure if I should keep with that structure or parse tags and make the torrent with tags on the filenames.
>> Anonymous
So, this version use KonaChan's API. (it must be faster, because no unnececary data load)

http://pastebin.com/m64a19934
>> Anonymous
>>514808
Here's my version, which doesn't needlessly hammer the fuck out of the server --

http://pastebin.com/m57abcbe7
>> Anonymous
>>514873

heh, pastebin.com isn't working now, so can you re-upload you code?

//This is mine (#514808)

http://pastebin.org/49842
>> Anonymous
>>514979
http://pastebin.org/49849
>> Anonymous
>>515010

Oh, konachan has "limit" arg. Your cod is much better than my :3

But i think that better to use the DEFAULT_LIMIT=1, because tags with 4 pages are unusual.
>> Anonymous
From KonaChan's API:
"limit: How many posts you want to retrieve. There is a hard limit of 100 posts per request."

Hmm, but it work for limit more than 100.

//515020-kun
>> Anonymous
Whoa, /w/ knows Python, nice.
>> Anonymous
>>515022
it won't display more than 100 posts in the xml list even if you put limit=9020
>> Anonymous
>>515063

It must be the error in api description:

~> konachan tagme|wc -l
1000
~> konachan touhou|wc -l
985

1000 is limit.
>> Anonymous
http://pastebin.com/f22fcce02

Look's like this version works good:

~> konachan tagme|wc -l
5823

>>515069-kun
>> Anonymous
>>515069
will check later if it's documentation description error or a bug
>> Anonymous
>>515081

I think description error because:

http://konachan.com/post/index.xml?tags=tagme&limit=1000&page=2

and

http://konachan.com/post/index.xml?tags=tagme&limit=373434&page=2

show offset="1000".
>> Anonymous
Hehe, looks like was changing something in konachan's code.

Now it redirected from direct link to link like:
http://konachan.com/post/show?md5=c52d4c79bff67c8590913e667fc2b917

This script print links this ?md5=.*
http://pastebin.com/m3c53dd49

And then you can download it:
wget -r -I image -R show* -nH --cut-dirs=2 -i list

(list - file this links)
>> Anonymous
>>515231
Just send the correct referer
wget -i name-of-list.txt --referer="http://konachan.com"
>> Anonymous
>>515237

Yeap, your variant is better.
>> Anonymous
yay asuka
>> Anonymous
I don't get all this code talk, is this ready or still being improved
>> Anonymous
>>515864

This version>>515074uses KonaChan's API (xml), max limit (1000), can work this tags > 1000 pics.
I think it's ready (for now, maybe konachan will change the code in future).
In my expirements this code works good.

P.S. If you want to download this links, you should send the correct referrer to the site (>>515237).
>> Anonymous
Some addition:

There is a RefControl addon for firefox:
https://addons.mozilla.org/en-US/firefox/addon/953
So, if you set the referrer "konachan.com" for site konachan.com you will see only image after click on direct link.
>> Anonymous
cool