commit bf7e9be04666a5fa32c1fe5432f2c243c0f56829
parent bde1492293821ac0f74fdd6325a5c25bc6aa9510
Author: Ryan Wolf <rwolf@borderstylo.com>
Date: Mon, 22 Feb 2010 17:31:55 -0800
outputting to file works, now for next paging
Diffstat:
4 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/LICENSE b/LICENSE
diff --git a/README.md b/README.md
diff --git a/eensyweensy.php b/eensyweensy.php
@@ -16,7 +16,14 @@ if (is_null($data["on_last_page"]) || !is_array($data["urls"])) {
$results["error"] = "validation error: missing on_last_page or urls";
}
else {
- $results["error"] = "not really an error, success!";
+ // http://www.tizag.com/phpT/fileappend.php
+ $file_name = "output.txt";
+ $file_handle = fopen($file_name, "a+");
+ foreach ($data["urls"] as $url) {
+ fwrite($file_handle, "$url\n");
+ }
+ fclose($file_handle);
+ $results["error"] = "yay";
}
echo json_encode($results);
diff --git a/eensyweensy.user.js b/eensyweensy.user.js
@@ -53,11 +53,17 @@ Spider.prototype.phone_home = function (data) {
};
Spider.prototype.handle_results = function (response) {
- var data = JSON.parse(response.responseText);
- if (data.error) {
- alert(data.error);
+ if (!response) { alert("no response"); return; }
+ var data;
+ // JSON.parse barfs top-level errors on failure
+ try {
+ data = JSON.parse(response.responseText);
+ }
+ catch (e) {
+ alert(JSON.stringify(response)); // debugging parties!
return;
}
+ if (data.error) { alert(data.error); return; }
};
Spider.prototype.go = function () {
@@ -74,6 +80,7 @@ spider.grabber = function ($) {
var next_page_button = $('.next_page');
var on_last_page = next_page_button.hasClass('disabled');
var data = {
+ href: document.location.href;
urls: urls,
on_last_page: on_last_page,
};