Advertisement
bejiitas_wrath

4chan scraper.

Apr 18th, 2023
989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php
  2.     $board = "b"; // replace this with the board name you want to scrape
  3.     $url = "https://boards.4chan.org/".$board."/"; // URL of the board
  4.     $page = file_get_contents($url); // get the page source of the board
  5.     preg_match_all('~https?://[^\s<>"]+|www\.[^\s<>"]+~i', $page, $matches); // match all URLs in the page source
  6.     $links = array_unique($matches[0]); // remove duplicates
  7.     foreach ($links as $link) {
  8.         if (strpos($link, "i.4cdn.org/".$board."/") !== false) { // check if the link is an image in the board
  9.             $filename = basename($link); // get the filename of the image
  10.             file_put_contents($filename, fopen($link, 'r')); // save the image to the server
  11.         }
  12.     }
  13. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement