This file contains hidden or 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
| var html = "<div><hr>foo<div>bar</div></div>"; | |
| var c = -1; | |
| html = html.replace(/\<([^<\>]*)\>/g, function(str, r) { | |
| if(r.indexOf("/") === -1) { | |
| c++; | |
| return "[\"" + r + ((c == 0) ? "\"," : "\"],"); |
This file contains hidden or 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
| Match any well formed tags | |
| (<([^<\>]*)>(.*?)</([^<\>]*)>|<([^<\>]*)/>) | |
| Match any tag (with a couple variations) or anything between tags | |
| (>[^<\>](.*?)<|<([^<\>]*)>|</([^<\>]*)>|<([^<\>]*)/>) | |
| -> First Group (i.e. anything between tags isn't matching in RegexBuddy) | |
| Match any tag (with one variation): | |
| (>[^<\>](.*?)<|<([^<\>]*)>) | |
| -> First Group (i.e. anything between tags isn't matching in RegexBuddy) |
This file contains hidden or 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
| var html = "<div><div>foo</div></div>" | |
| var split = html.split(/(<[^<\>]*>)/); | |
| var jup = ""; | |
| // Simple state machine: | |
| // 'start' : Last Saw Start Tag | |
| // 'content': Last Saw Content | |
| // 'end' : Last Saw End |
This file contains hidden or 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
| Charlies-MacBook-Pro:nodejitsu Charlie$ node | |
| Type '.help' for options. | |
| node> var jsdom = require('jsdom'); | |
| ########################################################### | |
| # WARNING: node-htmlparser could not be found. | |
| # Element.innerHTML setter support has been disabled | |
| # Element.innerHTML getter support will still function | |
| # Download: http://github.com/davglass/node-htmlparser | |
| ########################################################### |
This file contains hidden or 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
| Charlies-MacBook-Pro:node-cloudservers Charlie$ vows | |
| · | |
| http:909 | |
| parser.finish(); | |
| ^ | |
| TypeError: Cannot call method 'finish' of undefined | |
| at Client.onend (http:909:12) | |
| at IOWatcher.callback (net:495:28) | |
| at node.js:266:9 |
This file contains hidden or 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
| <SCRIPT TYPE="text/javascript"> | |
| var gDomain="sdc.bmi.com"; | |
| var gDcsId="dcsnnb9tr9wm1ic8m9wiosd8c_5q1q"; | |
| var gFpc="WT_FPC"; |
This file contains hidden or 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
| function parseQueryString(subject) { | |
| var results = {}; | |
| var parser = /[^&\?]+/g; | |
| var match = parser.exec(subject); | |
| while (match != null) { | |
| var parts = match[0].split('='); | |
| results[parts[0]] = parts[1]; | |
| match = parser.exec(subject); | |
| } | |
| return results; |
This file contains hidden or 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
| var sys = require('sys'), | |
| http = require('http'); | |
| process.on('uncaughtException', function (err) { | |
| sys.puts('Caught exception: ' + err); | |
| }); | |
| // Simple Example | |
| http.createServer(function (req, res) { | |
| res.writeHead(200, {'Content-Type': 'text/plain'}); |
This file contains hidden or 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
| var httpAgent = require('http-agent'), | |
| sys = require('sys'); | |
| var agent = httpAgent.create('www.google.com', ['finance', 'news', 'images']); | |
| agent.addListener('next', function (agent) { | |
| setTimeout(function () { | |
| sys.puts('Body of the current page: ' + agent.body); | |
| sys.puts('Response we saw for this page: ' + agent.response); |
This file contains hidden or 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
| var jsdom = require('jsdom'), | |
| sys = require('sys'); | |
| // | |
| // Remark: I have jsdom.createWindow working with complex HTML pages pulled from the wild intertubes :) | |
| // | |
| var window = jsdom.createWindow('<html><body><h1>Hello Server Side jQuery</h1></body></html>'); | |
| jsdom.jQueryify(window, '/path/to/jquery.js', function () { | |
| sys.puts(window.jQuery('h1')[0].innerHTML); |
OlderNewer