Author Topic: [Python] Multithreaded 4chan image downloader  (Read 1168 times)

0 Members and 1 Guest are viewing this topic.

Offline d4rkcat

  • Knight
  • **
  • Posts: 287
  • Cookies: 115
  • He who controls the past controls the future. He who controls the present controls the past.
    • View Profile
    • Scripts
[Python] Multithreaded 4chan image downloader
« on: December 14, 2014, 06:44:56 pm »
I wrote this after seeing this thread by Fur on a Ruby 4chan downloader.
I decided it was a nice idea and so gave it an upgrade to a real scripting language, python.
It is blazingly fast and if you have a great connection, you can increase the number of threads with the -n switch to make it even faster.

Usage:
Code: [Select]
./threaddumper.py -b b -t 584978710
Will download every image in the 584978710 thread on /b/

Code: [Select]
./threaddumper.py -b b -t 584978710 -m
Will download every image in the 584978710 thread on /b/ and then monitor the thread for new images and download them when available.

Code: [Select]
./chandumper.py -b b -q
Will download every image in every thread on /b/ and be quiet with the output.

threaddumper.py:

[gist]d4rkcat/a00241bc00bbbd4ba2ff[/gist]

chandumper.py:

[gist]d4rkcat/22b1343d97da7100b2ad[/gist]
« Last Edit: December 16, 2014, 02:54:40 pm by d4rkcat »
Jabber (OTR required): thed4rkcat@einfachjabber.de    Email (PGP required): thed4rkcat@yandex.com    PGP Key: here and here     Blog

<sofldan> not asking for anyone to hold my hand uber space shuttle door gunner guy.


Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [Python] Multithreaded 4chan image downloader
« Reply #1 on: December 14, 2014, 07:28:49 pm »
Very good, but is there any practical use of it?

Offline d4rkcat

  • Knight
  • **
  • Posts: 287
  • Cookies: 115
  • He who controls the past controls the future. He who controls the present controls the past.
    • View Profile
    • Scripts
Re: [Python] Multithreaded 4chan image downloader
« Reply #2 on: December 15, 2014, 03:18:43 am »
Very good, but is there any practical use of it?

LOL, no ofc not.
I guess someone could learn how download shit 30 times faster than normal.
It entertained me for an hour or so.
Jabber (OTR required): thed4rkcat@einfachjabber.de    Email (PGP required): thed4rkcat@yandex.com    PGP Key: here and here     Blog

<sofldan> not asking for anyone to hold my hand uber space shuttle door gunner guy.


Offline Psycho_Coder

  • Knight
  • **
  • Posts: 166
  • Cookies: 84
  • Programmer, Forensic Analyst
    • View Profile
    • Code Hackers Blog
Re: [Python] Multithreaded 4chan image downloader
« Reply #3 on: December 15, 2014, 06:41:24 am »
Good work. YOu could gain significant faster parsing and with lxml instead of beautiful soup. Also try to avoid urllib2 and move to python requests. urllib3 would be fine as well.
"Don't do anything by half. If you love someone, love them with all your soul. When you hate someone, hate them until it hurts."--- Henry Rollins

Offline d4rkcat

  • Knight
  • **
  • Posts: 287
  • Cookies: 115
  • He who controls the past controls the future. He who controls the present controls the past.
    • View Profile
    • Scripts
Re: [Python] Multithreaded 4chan image downloader
« Reply #4 on: December 16, 2014, 05:07:59 am »
Good work. YOu could gain significant faster parsing and with lxml instead of beautiful soup. Also try to avoid urllib2 and move to python requests. urllib3 would be fine as well.

Great ideas, done and done.
Thank you for your advice.  ;)
+1
Jabber (OTR required): thed4rkcat@einfachjabber.de    Email (PGP required): thed4rkcat@yandex.com    PGP Key: here and here     Blog

<sofldan> not asking for anyone to hold my hand uber space shuttle door gunner guy.