]> git.quilime.com - visual-archive.git/commitdiff
writing to file
authorGabriel Dunne <gdunne@quilime.com>
Fri, 22 Mar 2013 09:35:16 +0000 (02:35 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Fri, 22 Mar 2013 09:35:16 +0000 (02:35 -0700)
phantom-scrape-thumbnail.js [new file with mode: 0644]
phantom-scrape.js [moved from scrape-mult.js with 81% similarity]
scrape-from-json.js [new file with mode: 0644]
scrape-id.js [new file with mode: 0644]
scrape.js [deleted file]

diff --git a/phantom-scrape-thumbnail.js b/phantom-scrape-thumbnail.js
new file mode 100644 (file)
index 0000000..9724f6a
--- /dev/null
@@ -0,0 +1,11 @@
+var system = require('system'),
+    page = require('webpage').create();
+
+page.open(system.args[1], function () {
+    var th = page.evaluate(function () {
+        return document.getElementById('thumbnail').src;
+    });
+    console.log(th);
+    //console.log(JSON.stringify({ thumbnail : th }));
+    phantom.exit();
+});
similarity index 81%
rename from scrape-mult.js
rename to phantom-scrape.js
index 55c3afe0700e9f66ab799d7f2f0c875a485d2a2f..596c703d8f82df8af224b4932702236881d6fdcc 100644 (file)
@@ -1,17 +1,11 @@
 var system = require('system');
 var page = require('webpage').create();
-
-var prelinger_ids = require('./prelinger_identifiers.json');
-var ids = prelinger_ids.identifiers;
 var url_details = "http://archive.org/details/";
 
 if (system.args.length === 1) {
     console.log('Identifier Required');
 } else {
     var id = system.args[1];
-
-
-
     page.open(url_details + id, function () {
         var th = page.evaluate(function () {
             return document.getElementById('thumbnail').src;
diff --git a/scrape-from-json.js b/scrape-from-json.js
new file mode 100644 (file)
index 0000000..ef857f4
--- /dev/null
@@ -0,0 +1,28 @@
+var exec = require('child_process').exec;
+var fs  = require("fs");
+
+// fs.readFileSync('./input.txt').toString().split('\n').forEach(function (line) {
+//     console.log(line);
+//     fs.appendFileSync("./output.txt", line.toString() + "\n";
+// });
+
+var prelinger = require('./prelinger_identifiers.json');
+
+var output = { "clips" : [] };
+for (var i = 0; i < prelinger.identifiers.length; i++) {
+    var id = prelinger.identifiers[i];
+    output.clips[i] = { "id" : id };
+}
+
+fs.open("./output.txt", 'w', 0666, function(err, fd) {
+  fs.writeSync(fd, JSON.stringify(output) + "\n", null, undefined, function(err, written) {
+  })
+});
+
+// "http://archive.org/details/" +
+
+// var id = '0924_Greatest_Name_in_Wine_The_11_00_13_15';
+// cmd = spawn('phantomjs' ['phantom-scrape-id.js']);
+
+
+
diff --git a/scrape-id.js b/scrape-id.js
new file mode 100644 (file)
index 0000000..596c703
--- /dev/null
@@ -0,0 +1,16 @@
+var system = require('system');
+var page = require('webpage').create();
+var url_details = "http://archive.org/details/";
+
+if (system.args.length === 1) {
+    console.log('Identifier Required');
+} else {
+    var id = system.args[1];
+    page.open(url_details + id, function () {
+        var th = page.evaluate(function () {
+            return document.getElementById('thumbnail').src;
+        });
+        console.log(th);
+        phantom.exit();
+    });
+}
diff --git a/scrape.js b/scrape.js
deleted file mode 100644 (file)
index edb3e47..0000000
--- a/scrape.js
+++ /dev/null
@@ -1,15 +0,0 @@
-
-var identifier = "animals_in_the_service_of_man_2";
-var url_details = "http://archive.org/details/";
-
-var page = require('webpage').create();
-page.open(url_details + identifier, function () {
-    // page.render('page.png');
-
-    var ua = page.evaluate(function () {
-        return document.getElementById('thumbnail').src;
-    });
-
-    console.log(ua);
-    phantom.exit();
-});