Posted in Programming by Mr. Novocain on August 5, 2010 at 07:15

chanSaver

This might interest you: Simple PHP - Learn Php In 17 Hours

Download

Save images from your favorite chan imageboards.
Tested and working on 4chan and 2chan.

Just enter thread URL and it will create a directory with the name of that thread, then start leeching all of the images.


Source code (Neverfail.cs)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8.  
  9. using System.IO;
  10. using System.Net;
  11. using System.Text.RegularExpressions;
  12. using System.Threading;
  13.  
  14. namespace _chanSaver
  15. {
  16.     public partial class Neverfail : Form
  17.     {
  18.         public Neverfail()
  19.         {
  20.             InitializeComponent();
  21.         }
  22.  
  23.         string content = "";
  24.         string threadname = "";
  25.  
  26.         private void btnGo_Click(object sender, EventArgs e)
  27.         {
  28.             btnGo.Enabled = false;
  29.  
  30.             label1.Text = "";
  31.             lblProgress.Text = "";
  32.             progressBar1.Value = 0;
  33.             progressBar1.Maximum = 0;
  34.  
  35.             content = "";
  36.             WebClient x = new WebClient();
  37.             content = x.DownloadString(txtURL.Text);
  38.             string[] urlparts = txtURL.Text.Split(‘/’);
  39.             threadname = urlparts[5];
  40.             if (threadname.Contains(".")) { threadname = threadname.Substring(0, threadname.IndexOf(‘.’)); }
  41.             txtURL.Text = "";
  42.  
  43.             Thread workThread = new Thread(new ThreadStart(WorkThread));
  44.             workThread.Start();
  45.         }
  46.  
  47.         private void WorkThread()
  48.         {
  49.             label1.Text = "Leeching..";
  50.  
  51.             MatchCollection matches = Regex.Matches(content, @”\<a><img alt="" />[\S]*?)"" target=""_blank""\>\d+.(jpg|jpeg|gif|bmp|png)\<\/a\>-\(", RegexOptions.IgnoreCase);
  52.             progressBar1.Maximum = matches.Count;
  53.  
  54.             Directory.CreateDirectory(threadname);
  55.  
  56.             foreach (Match match in matches)
  57.             {
  58.                 GroupCollection groups = match.Groups;
  59.  
  60.                 string imagename = "";
  61.                 string[] parts = groups["image"].Value.Split(‘/’);
  62.                 foreach (string part in parts)
  63.                     imagename = part;
  64.                 imagename = threadname + "/" + imagename;
  65.  
  66.                 while(!File.Exists(imagename))
  67.                 {
  68.                     WebClient y = new WebClient();
  69.                     try
  70.                     {
  71.                         y.DownloadFile(groups["image"].Value, imagename);
  72.                     }
  73.                     catch(System.Net.WebException we)
  74.                     {
  75.                         break;
  76.                     }
  77.                     Thread.Sleep(500);
  78.                 }
  79.  
  80.                 progressBar1.Value++;
  81.                 progressBar1.Refresh();
  82.  
  83.                 lblProgress.Text = progressBar1.Value + " / " + progressBar1.Maximum;
  84.                 lblProgress.Refresh();
  85.             }
  86.  
  87.             label1.Text = "Done! Fkn saved " + progressBar1.Maximum + " images. Now leech next thread fag.";
  88.             btnGo.Enabled = true;
  89.         }
  90.     }
  91. }</a>

Incoming search terms for the article:

 

Leave a Reply