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

4chan Source Code

Name: Anonymous 2007-08-01 6:28 ID:rpojcmHJ

Is there anywhere to download the source code of 4chan/other image boards? I'd like to see it just out of curiosity and to possibly set one up for myself and friends.

Name: Anonymous 2008-10-30 12:46

>>69
sub get_thread($$){
    my $self=shift;
    my($thread)=@_;

    my($err,$res)=$self->wget($self->link_thread($thread));
    $err and return $err;
   
    my $t;
    while($res=~m!(
            (?:
                (?:
                    <(span) \s class="filesize">(?>.*?</blockquote>)
                    |
                    <img \s src="[^"]*" alt="File \s deleted\.">
                )
                (?:<span \s class="omittedposts">[^<]*</span>)?
            )
            |
            (?:<table><tr><td \s nowrap \s class="doubledash">(?>.*?</blockquote></td></tr></table>))
    )!gxs){
        my($text,$type)=($1,$2);
        if($type){
            $self->troubles("two thread posts in one thread------$res------") and return
                if $t;
            $t=$self->parse_thread($text);
        }else{
            $self->troubles("posts without thread------$res------") and return
                unless $t;
           
            push @{$t->{posts}},$self->parse_post($text,$t->{num});
        }
    }
   
    $t;
}
sub parse_thread($$){
    my $self=shift;
    my($text)=@_;
    $text=~m!    (?:
                    <a \s href="([^"]*/src/\d+\.\w+)"[^>]*>[^<]*</a> \s*
                    \- \s* \((Spoiler \s Image,)?([\d\sGMKB\.]+)\, \s (\d+)x(\d+)(?:, \s* <span \s title="([^"]*)">[^<]*</span>)?\) \s*
                    </span> \s*
                    (?:
                        <br>\s*<a[^>]*><img \s+ src=\S* \s+ border=\S* \s+ align=\S* \s+ (?:width="?(\d+)"? \s height="?(\d+)"?)? [^>]*? md5="?([\w\d\=\+\/]+)"? [^>]*? ></a> \s*
                        |
                        <a[^>]*><span \s class="tn_thread"[^>]*>Thumbnail \s unavailable</span></a>
                    )
                    |
                    <img [^>]+ alt="File \s deleted\.">
                )
                <a[^>]*></a> \s*
                <input \s type=checkbox \s name="(\d+)"[^>]*><span \s class="filetitle">(?>(.*?)</span>) \s*
                <span \s class="postername">(?:<a \s href="mailto:([^"]*)"[^>]*>)?([^<]*?)(?:</a>)?</span>
                (?: \s* <span \s class="postertrip">([a-zA-Z0-9\.\+/\!]+)(?:</a>)?</span>)?
                \s ([^>]*) \s \s* <span[^>]*> \s*
                (?>.*?</span>) \s*
                <blockquote>(?>(.*?)</blockquote>)
                (?:<span \s class="omittedposts">(?:(\d+)(?:.*?(\d+)).*?)?</span>)?
    !xs or $self->troubles("error parsing thread\n------\n$text\n------\n") and return;

    $self->new_thread(
        num            => $10,
        omposts        =>($17 or 0),
        omimages    =>($18 or 0),
        posts        =>[$self->new_yotsuba_post(
            $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,0
        )],
    )
}

sub parse_post($$$){
    my $self=shift;
    my($text,$parent)=@_;
    $text=~m!    <td \s id="(\d+)"[^>]*> \s*
                <input[^>]*><span \s class="replytitle">(?>(.*?)</span>) \s*
                <span \s class="commentpostername">(?:<a \s href="mailto:([^"]*)"[^>]*>)?([^<]*?)(?:</a>)?</span>
                (?: \s* <span \s class="postertrip">([a-zA-Z0-9\.\+/\!]+)(?:</a>)?</span>)?
                \s ([^>]*) \s \s* <span[^>]*> \s*
                (?>.*?</span>) \s*
                (?:
                    <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \s*
                    <span \s class="filesize">File \s :
                    <a \s href="([^"]*/src/\d+\.\w+)"[^>]*>[^<]*</a> \s*
                    \- \s* \((Spoiler \s Image,)?([\d\sGMKB\.]+)\, \s (\d+)x(\d+)(?:, \s* <span \s title="([^"]*)">[^<]*</span>)?\)
                    </span> \s*
                    (?:
                        <br>\s*<a[^>]*><img \s+ src=\S* \s+ border=\S* \s+ align=\S* \s+ (?:width=(\d+) \s height=(\d+))? [^>]*? md5="?([\w\d\=\+\/]+)"? [^>]*? ></a> \s*
                        |
                        <a[^>]*><span \s class="tn_reply"[^>]*>Thumbnail \s unavailable</span></a>
                    )
                    |
                    <br> \s*
                    <img [^>]* alt="File \s deleted\." [^>]* > \s*
                )?
                <blockquote>(?>(.*?)</blockquote>)</td></tr></table>
    !xs or $self->troubles("error parsing post\n------\n$text\n------\n") and return;
   
    $self->new_yotsuba_post(
        $7,$8,$9,$10,$11,$12,$13,$14,$15,$1,$2,$3,$4,$5,$6,$16,$parent
    )
}

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