-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from ogewan/future
Future
- Loading branch information
Showing
65 changed files
with
3,970 additions
and
2,066 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
*.old | ||
_site/ | ||
.DS_Store | ||
*.jar | ||
*.bat | ||
swatches.html | ||
swatches.html | ||
node_modules/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @module cngn_node | ||
* Creates a script for a given webcomic via webcrawling. | ||
*/ | ||
var request = require('request'), | ||
url = require('url'), | ||
base = 'https://www.xkcd.com/', | ||
linkdct = { | ||
[base]: true | ||
}, | ||
queue = [base], | ||
active, | ||
imgdct = {}, | ||
getback = function() { | ||
if (queue.length) { | ||
active = queue.pop(); | ||
request(active, function(err, response, body) { | ||
if (err) throw err; | ||
var resultlist = parseHTML(body); | ||
return getback(); | ||
}); | ||
} | ||
return imgdct; | ||
}, | ||
parseHTML = function(str) { | ||
var result, arr = str.split(/<|>/g); | ||
result = arr.filter(function(ele) { | ||
var nde = ele.split(" ")[0]; | ||
return nde == "a" || nde == "img"; | ||
}); | ||
result = result.map(function(ele) { | ||
var nde = ele.split(" "), | ||
obj = {}, | ||
tmp; | ||
for (var i = 0; i < nde.length; i++) { | ||
if (!i) { | ||
obj.type = nde[0]; | ||
} else { | ||
tmp = nde[i].split("="); | ||
if (tmp[0] == "href") { | ||
tmp[1] = tmp[1].replace(/"/g, ""); | ||
if (tmp[1].indexOf(base) + 1 || 1) { | ||
if (!linkdct[tmp[1]]) { | ||
linkdct[tmp[1]] = true; | ||
queue.push(tmp[1]); | ||
} | ||
} | ||
} else if (tmp[0] == "src") { | ||
tmp[1] = tmp[1].replace('"', ""); | ||
imgdct[tmp[1]] = imgdct[tmp[1]] + 1 || 1; | ||
} | ||
} | ||
} | ||
return obj; | ||
}); | ||
return result; | ||
}; | ||
|
||
//get('https://www.xkcd.com/').asString(function(err, data) { | ||
getback(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "cngn_node", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "main.js", | ||
"author": "ogewan", | ||
"license": "ISC", | ||
"dependencies": { | ||
"get": "^1.4.0", | ||
"install": "^0.10.4", | ||
"jsdom": "^11.6.2" | ||
} | ||
} |
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.