Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "use strict";
- var request = require("request");
- var readline = require("readline");
- var os = require("os");
- var fs = require("fs-extra");
- var Crawler = require("crawler");
- var url = require("url");
- var Promise = require("bluebird");
- const rl = readline.createInterface({
- input: process.stdin,
- output: process.stdout
- });
- var archivePoint = -1;
- var filePath2 = __dirname;
- var fileCount = 0;
- var threadSize = 10000;
- var threadMaxSize = 1000000; // Not sure atm
- const redditUrl = "https://reddit.com/r/pizzagate/comments/";
- var hotArchiveUrlSearch = "https://www.reddit.com/r/pizzagate/";
- console.log("Welcome patriot. #PizzaGate is being shut down and American values are being destroyed.");
- console.log("We have until 4PM PST to archive everything important");
- console.log("Enter either 0-9 based off of the day you were born % 10. So if you were born on the 11th you are a 1. If you are born on the 9th you are a 9. 22nd = 2. 10th = 0");
- console.log("Enter all to start archiving everything!");
- rl.question("Enter `all` or `1-10` without the `:", function(answer) {
- if (answer === "all") archivePoint = -1;
- else if (Number.isInteger(parseInt(answer)) && (parseInt(answer) <= 9 || parseInt(answer) >= 0)) {
- archivePoint = parseInt(answer);
- }
- rl.question("Enter a absolute file dir path to save to (C:\ or / [linux based] or leave blank [default current dir]): ",
- function(filePathIn) {
- if (filePathIn) filePath2 = filePathIn;
- startArchiving();
- });
- });
- function startArchiving() {
- console.log("Starting to archive...");
- console.log("Creating new directory at: " + filePath2);
- var c = new Crawler({
- maxConnections: 10,
- callback: function(error, result, $) {
- new Promise(function(resolve, reject) {
- var saveCount = 0;
- var fileTrueCount = fileCount;
- console.log("visited new index page");
- fs.ensureDir(filePath2 + "/" + fileTrueCount, function(err) {
- console.log("ensuring dir");
- fs.outputFile(filePath2 + "/" + fileTrueCount + "/" + "index.html", result.body, function(err) {
- console.log("saved: " + filePath2 + "/" + fileTrueCount + "/" + "index.html");
- $('.comments').each(function(index, a) {
- var toQueueUrl = $(a).attr("href");
- request(toQueueUrl, function(err, res, body) {
- fs.outputFile(filePath2 + "/" + fileTrueCount + "/" + saveCount + ".html", res.body, function(err) {
- console.log("saved: " + filePath2 + "/" + fileTrueCount + "/" + saveCount + ".html");
- });
- saveCount++;
- });
- });
- });
- });
- resolve($(".next-button a").attr("href"));
- }).then(function(url){
- fileCount++;
- c.queue(url);
- });
- }
- });
- c.queue(hotArchiveUrlSearch);
- }
Add Comment
Please, Sign In to add comment