Skip to content

Instantly share code, notes, and snippets.

@vtronko
Last active August 28, 2016 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vtronko/7395c69ceb0e8087d100db8005abe88a to your computer and use it in GitHub Desktop.
Save vtronko/7395c69ceb0e8087d100db8005abe88a to your computer and use it in GitHub Desktop.
import json, requests, urllib
url = 'https://2ch.hk/api/captcha/2chaptcha/id'
imageurl = 'https://2ch.hk/api/captcha/2chaptcha/image/'
count = 100
dirname = '/home/innermous/Downloads/' # leave this field empty to download into current directory
for x in range(0, count):
r = requests.get(url)
json_data = json.loads(r.text)
imagehash = json_data["id"]
src = imageurl + imagehash
filename = "{cat}captcha{num}.png".format(cat=dirname, num=x)
urllib.request.urlretrieve(src, filename)
print("Loaded {num} of {total}".format(num=x+1, total=count))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment