Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

A Ruby gift for you, /prog/

Name: Anonymous 2010-05-10 1:41

gem install hpricot
ruby fukkensaved.rb

-------------------
# fukkensaved.rb
# scrape an entire thread's worth of pictures from /b/

require 'rubygems'
require 'open-uri'
require 'hpricot'

USER_AGENT = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1b4) Gecko/20090423 Firefox/3.5b4 GTB5 (.NET CLR 3.5.30729)'

def fetch_thread(thread_id)
  Hpricot(open("http://boards.4chan.org/b/res/#{thread_id}", 'User-Agent' => USER_AGENT))
end

def save_image(thread_no, url)
  if !File.exists?("#{thread_no}/#{File.basename(url)}")
    f = File.open("#{thread_no}/#{File.basename(url)}", 'wb')
 
    open(url, 'User-Agent' => USER_AGENT) do |i|
      f.write(i.read)
    end
 
    f.close 
  end
end

print "Thread number? "
thread_id = gets.chomp

puts "Loading thread #{thread_id}..."

imgs = fetch_thread(thread_id).search("img[@md5]")

# Make a directory based on the thread number
Dir.mkdir(thread_id) unless File.directory? thread_id

# Download each image to this new directory
imgs.each do |img|
  puts "Downloading file #{img.parent.attributes['href']}..."
  save_image(thread_id, img.parent.attributes['href'])
end

Name: Anonymous 2010-05-10 2:01

Windows NT 6.0
Firefox/3.5b4 GTB5 (.NET CLR 3.5.30729)
what.

Name: Anonymous 2010-05-10 2:05

Just a phony useragent so it doesn't show up as open-uri or whatever in the logs. I suppose it should be randomized between five or ten different ones.

Personally my useragent is Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7 :)

Name: Anonymous 2010-05-10 3:52

and the reason anyone would use this slow as fuck shitfest instead of one line with wget is...?

Name: Anonymous 2010-05-10 9:03

Because Ruby is the shit.

Name: Anonymous 2010-05-10 9:28

ruby can hax my anus any day of the week

Name: Anonymous 2010-05-10 9:40

scrape an entire thread's worth of pictures from /b/
gee, thanks. It's what I've always wanted *sigh*

Name: Anonymous 2010-05-10 9:51

require 'hpricot'

Don't. Since his suicide, his code was frozen for posterity, without concern for security issues.

Name: Anonymous 2010-05-10 11:08

HPRICOT MY ANUS

Name: Anonymous 2010-05-10 11:35

why my lucky anus

Name: Anonymous 2010-05-10 11:59

Too bad the thread will be gone by the time the script finishes.

Name: Anonymous 2010-05-10 12:54

wget http://boards.4chan.org/b/$1 | egrep -O- 'http://images.4chan.org/b/src/[0-9];+\.(jpg|gif|png)' | sort -u | wget -i-

The generalization for any imageboard is left to the user.

Name: Anonymous 2010-05-10 13:51

wget http://boards.4chan.org/$2/$1 | egrep -O- 'http://images.4chan.org/$2/src/[0-9];;+\.(jpg|gif|png)' | sort -u | wget -i-

Name: Anonymous 2010-05-10 14:54

>>12-13
wget -A.gif,.jpg,.png -erobots=off -I/$1/src -nd -rH http://boards.4chan.org/$1/res/$2

Name: Anonymous 2010-05-10 14:58

Name: Anonymous 2010-05-10 19:11

I wish I were the only one outside Japlandia to know of Ruby so I wouldn't be so ashamed of using such a nice language.

Name: Anonymous 2010-05-10 19:14

>>16
code your ruby with pride

Name: Anonymous 2010-05-10 19:25

Ruby is a better Perl, or a worse Python.

Name: Anonymous 2010-05-10 19:27

Ruby is a worse Perl, or an equal Python.

Name: Anonymous 2010-05-10 20:06

Ruby is more enjoyable to use than its main competitors once you learn to pretend the community doesn't exist.

Name: Anonymous 2010-05-10 20:48

>>19
Still deep in denial, I see. It's unhealthy, you know? Face up to the fact that you made a mistake and move on.

Name: Anonymous 2010-05-10 21:07

>>21
I am more inclined to agree with >>19 than >>18

Name: Anonymous 2010-05-10 21:39

>>20
Funny, that applies to Python too.

Name: Anonymous 2010-05-10 22:37

>>22
I hope you don't mind being wrong as well, then.

Name: Anonymous 2010-05-10 22:51

>>23
And Haskell.
Really, all programming communities are shit.

Name: Anonymous 2010-05-10 23:27

>>24
Wrong on a matter of opinion? It's like I'm really on the internet. I'll concede: you can be king retard.

Name: Anonymous 2010-05-11 0:29

>>26
No, no, I insist, take the crown - you should be the leader!

Name: Anonymous 2010-05-11 1:48

>>26
The fact that Perl is a terrible language isn't a matter of opinion any more than the fact that Java or PHP are terrible languages is.

Name: Anonymous 2010-05-11 3:29

>>28
The only way one person could be against both PHP and Perl is if she's too stupid to understand Perl.

Name: Anonymous 2010-05-11 4:42

>>29
understand Perl

Name: Anonymous 2010-05-11 5:39

>>30
UNDERSTAND MY ANUS

Name: Anonymous 2010-05-11 8:29

>>29
she
IHBT

Name: Anonymous 2011-01-31 21:01

<-- check em dubz

Name: Anonymous 2011-02-04 17:13

Name: Gruff 2011-03-06 19:55

Its true, almos tall languages ive learnt ive had t oshut myself away from the community, for being such unhelpful bastards

Name: Anonymous 2011-03-06 23:27

>>29
``she''

Emacs user detected

Name: >>29 2011-03-07 0:02

>>36
Emacs is too old-fashioned and arcane.  I use TextMate: Watch the Screencasts.

Name: Anonymous 2011-03-07 0:14


wget -N -k -c -l1 -r -A.jpg,.gif,.png,.jpeg,.html, -Dimages.4chan.org,thumbs.4chan.org -H -p -e robots=off $@


where is your ruby now?

Name: Anonymous 2011-03-07 3:17

>>3
i might be a bit late to the party here (hence the bump), but you should know about this little website here:
http://panopticlick.eff.org/

Name: Anonymous 2011-03-07 6:11

Wow wget seems pretty cool, let's learn some of this beautiful wizardry:

man wget

Hum....this seems a huge manual:

man wget | wc -l

2497

Fuck this.

Don't change these.
Name: Email:
Entire Thread Thread List