- Joined
- Aug 19, 2007
- Messages
- 4,941
- Solutions
- 11
- Reaction score
- 352
So, basically I am releasing my old script that will get images from 4Chan for you, because it is slower than my current one written with cURL extension.
Way to use it:
1. ?do=1/pages/page/only -> Will get you images from 15 main /b/ pages.
2. ?do=2/thread/threadid&thread=id_here -> Will get you images from specified thread.
3. ?do=3/all/threads&from=page&to=page -> Will get you images from threads that are on specified pages (from -> to).
Have fun, bye.
PHP:
<?php
set_time_limit(0);
$keys = array();
$values = array();
$do = strtolower($_GET['do']); //Action type.
$threadid = $_GET['thread']; //Simple thread id.
$threadsFrom = $_GET['from']; //Page number to start from.
$threadsTo = $_GET['to']; //Page number to end at.
$chan = "";
$trds = "";
if(in_array($do, array("page", "pages", "only", 1)))
for($p = 1; $p < 16; $p++)
$chan .= @file_get_contents("http://boards.4chan.org/b/{$p}");
elseif(in_array($do, array("thread", "threadid", 2)))
$chan .= @file_get_contents("http://boards.4chan.org/b/res/{$threadid}");
elseif(in_array($do, array("threads", "all", 3)))
{
$threadsFrom = ($threadsFrom < 1 || $threadsFrom > 15) ? 1 : $threadsFrom;
$threadsTo = $threadsTo > 15 ? 15 : $threadsTo;
$threadsTo = $threadsTo >= $threadsFrom ? $threadsTo : $threadsFrom;
for($p = $threadsFrom; $p <= $threadsTo; $p++)
$trds .= @file_get_contents("http://boards.4chan.org/b/{$p}");
preg_match_all('/\<input type\=checkbox name\="(.*?)" value\=(.*?)>/is', $trds, $tMatches);
foreach($tMatches[1] as $t)
$chan .= @file_get_contents("http://boards.4chan.org/b/res/{$t}");
}
else
{
echo "I don't know wtf are you doin', but you're doin' it wrong.";
exit;
}
preg_match_all('/\<a href\="http:\/\/images\.4chan\.org\/b\/src\/(.*?)" target\=(.*?)\>\<img src\=(.*?)\>\<\/a\>/is', $chan, $matches);
str_replace("align=left", "", $matches[0]);
foreach($matches[1] as $val)
$values[] = $val;
foreach($matches[3] as $th)
{
$th = explode(" ", $th);
$keys[] = $th[0];
}
$content = "";
if(count($keys))
$content .= "<div align=\"center\">Output: ".count($keys)." images.</div><br />";
for($i = 0; $i <= count($values); $i++)
if(!empty($keys[$i]))
{
if($i % 5 == 0)
$content .= "<br /><br />";
$content .= "<a href=\"http://images.4chan.org/b/src/{$values[$i]}\"><img src=\"{$keys[$i]}\" /></a> ";
}
echo $content;
?>
Way to use it:
1. ?do=1/pages/page/only -> Will get you images from 15 main /b/ pages.
2. ?do=2/thread/threadid&thread=id_here -> Will get you images from specified thread.
3. ?do=3/all/threads&from=page&to=page -> Will get you images from threads that are on specified pages (from -> to).
Have fun, bye.
Last edited: