我用这个例子来创建一个phantomjs代码来登录网站.
var page = require('webpage').create();
page.open("http://www.facebook.com/login.php", function(status) {
if (status === "success") {
page.onConsoleMessage = function(msg, lineNum, sourceId) {
console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")');
};
page.evaluate(function() {
console.log('hello');
document.getElementById("email").value = "email";
document.getElementById("pass").value = "password";
document.getElementById("u_0_1").click();
// page is redirecting.
});
setTimeout(function() {
page.evaluate(function() {
console.log('haha');
});
page.render("page.png");
phantom.exit();
}, 5000);
}
});
Run Code Online (Sandbox Code Playgroud)
从这个链接. https://gist.github.com/ecin/2473860
但我想从按钮打开另一个链接或直接在它上面.我该怎么做?
这是一个更简单的例子.不起作用......
var page = require('webpage').create();
var url = "www.example.com";
page.open(url, function …Run Code Online (Sandbox Code Playgroud) 我有700多个链接要检查,它们是来自网站的长链接.它们是受信任的,但FireFox不会将它们视为可信任的.那么如何禁用"此连接不受信任"或快速添加大量链接?
我正在寻找这个问题的答案,但没有找到。有没有人有解决此类问题的方法。我有一组文本变量,必须使用 Java 将它们写入 .CSV 文件中。我目前正在做一个使用 JavaScript 的项目,需要 Java。这是我现在拥有的一个函数,可以很好地完成工作并将文本逐行写入 .CSV。
function writeFile(filename, data)
{
try
{
//write the data
out = new java.io.BufferedWriter(new java.io.FileWriter(filename, true));
out.newLine();
out.write(data);
out.close();
out=null;
}
catch(e) //catch and report any errors
{
alert(""+e);
}
}
Run Code Online (Sandbox Code Playgroud)
但现在我必须像下面的例子一样一篇一篇地写出部分文本。
first0,second0,third0
first1,second1,third1
first2,second2,third2
.
.
.
first9,second9,third9
Run Code Online (Sandbox Code Playgroud)
所以算法是这样的。该函数用逗号写入first0,然后转到下一行写入first1,转到下一行写入first2,依此类推,直到first9。该部分完成后,脚本将转到文件开头并在逗号后面写入 secondary0,转到下一行并在逗号后面写入 secondary1,依此类推。你明白了。
所以现在我需要java
我想知道如何将jQuery库包含到javascript中并在iMacros中使用它?
它是这样的.进入.js文件我将iMacros代码声明为变量
var someMacro;
someMacro ="CODE:";
someMacro +="TAB T=1 \n";
Run Code Online (Sandbox Code Playgroud)
代码实际上更大,这只是一个小例子.在我声明变量之后,我使用像iimPlay,iimSet等命令来播放宏并在宏内部设置变量.
现在我如何在其中包含jQuery库,以便我可以在.js文件中使用jQuery并增强我的脚本?
PS我在他们的论坛上发现了这个,但它对我帮助不大,因为我不明白如何使用它.这是链接到iopus论坛关于jQuery的链接
我正在使用node.js在Ubuntu服务器上运行JavaScript代码我收到此错误.
module.js:340
throw err;
^
Error: Cannot find module './lib/compat'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/lib/nodejs/node_modules/express/node_modules/depd/index.js:11:24)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Run Code Online (Sandbox Code Playgroud)
如何调试此错误?
编辑:使用这些依赖项.
var express = require('express');
var fs = require('fs');
var request = require('request');
var cheerio = require('cheerio');
Run Code Online (Sandbox Code Playgroud) 我已经做了这个解决方案。
var arr=[4,10,24,3,2,2,19];
var max = arr[0];
var maxIndex = 0;
var min = arr[0];
var minIndex = 0;
for (var i = 1; i < arr.length; i++) {
if (arr[i] > max) {
maxIndex = i;
max = arr[i];
}
}
for (var i = 1; i < arr.length; i++) {
if (arr[i] < min) {
minIndex = i;
min = arr[i];
}
}
alert(maxIndex);
alert(minIndex);
Run Code Online (Sandbox Code Playgroud)
有没有更简单的方法来完成上述任务?