<div>
<p>内容<span>我不获取的内容</span>内容</p>
</div>
var str = $('div p').contents().filter(function (index, content) {
return content.nodeType === 3;
}).text();
(function(global) { | |
if (global.define) { | |
return; | |
} | |
/* eslint strict:0 */ | |
var modules = {}; | |
var inGuard = false; | |
function def(id, deps, factory) { |
//http://www.cnblogs.com/gaizai/p/4233780.html | |
//https://www.v2ex.com/t/388152?p=2 | |
(function () { | |
'use strict'; | |
function string10to62(number) { | |
var chars = '0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ'.split(''); | |
var radix = chars.length; | |
var qutient = +number; | |
var arr = []; |
/* | |
* Copyright (c) 2010 Apple Inc. All rights reserved. | |
*/ | |
function characterNeedsScoreMultiplier(e) { | |
if (!e || e.length === 0) | |
return !1; | |
var t = e.charCodeAt(0); | |
return t > 11904 && t < 12031?!0 : t > 12352 && t < 12543?!0 : t > 12736 && t < 19903?!0 : t > 19968 && t < 40959?!0 : t > 44032 && t < 55215?!0 : t > 63744 && t < 64255?!0 : t > 65072 && t < 65103?!0 : t > 131072 && t < 173791?!0 : t > 194560 && t < 195103?!0 : !1 | |
} | |
function domDistance(e, t, n) { |
//http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport/7557433#7557433 | |
function isElementInViewport (el) { | |
//special bonus for those using jQuery | |
if (typeof jQuery === "function" && el instanceof jQuery) { | |
el = el[0]; | |
} | |
var rect = el.getBoundingClientRect(); |
<div>
<p>内容<span>我不获取的内容</span>内容</p>
</div>
var str = $('div p').contents().filter(function (index, content) {
return content.nodeType === 3;
}).text();
TESTS = $(shell ls -S `find test -type f -name "*.test.js" -print`) | |
REPORTER = spec | |
TIMEOUT = 10000 | |
MOCHA_OPTS = | |
install: | |
@tnpm install | |
standard: | |
@node_modules/.bin/standard |
function resizeIframe(obj) { | |
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px'; | |
} |
function addOrUpdateUrlParam(name, value) { | |
var href = window.location.href; | |
var regexPage = /[&\?]page=\d+/; | |
href = decodeURIComponent(href.replace(regexPage, "")); | |
var regex = new RegExp("[&\\?]" + name + "="); | |
if (regex.test(href)) { | |
//regex = new RegExp("([&\\?])" + name + "=(\\w+(,\\w+)\*)"); | |
regex = new RegExp("([&\\?])" + name + "=((\\w+(,\\w+)\*)|([\\u4e00-\\u9fa5]*\\/?[\\u4e00-\\u9fa5]\*))"); | |
if (regex.test(href)) { | |
window.location.href = href.replace(regex, "$1" + name + "=" + value); |
//PhantomJS http://phantomjs.org/ based web crawler Anton Ivanov [email protected] 2012 | |
//UPDATE: This gist has been made into a Node.js module and now can be installed with "npm install js-crawler" | |
//the Node.js version does not use Phantom.JS, but the API available to the client is similar to the present gist | |
(function(host) { | |
function Crawler() { | |
this.visitedURLs = {}; | |
}; | |
// This example shows how to render pages that perform AJAX calls | |
// upon page load. | |
// | |
// Instead of waiting a fixed amount of time before doing the render, | |
// we are keeping track of every resource that is loaded. | |
// | |
// Once all resources are loaded, we wait a small amount of time | |
// (resourceWait) in case these resources load other resources. | |
// | |
// The page is rendered after a maximum amount of time (maxRenderTime) |