首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CasperJS:作为参数的查询字符串不起作用

CasperJS:作为参数的查询字符串不起作用
EN

Stack Overflow用户
提问于 2013-11-15 10:06:44
回答 1查看 1.5K关注 0票数 0

我使用casperjs,它在传递url时不起作用,url有一些查询字符串,比如https://www.google.co.in/imghp?ie=UTF-8&hl=en&tab=wi&ei=ne6FUuvXIIiPrgeN-YGQDA&ved=0CAMQqi4oAg。我正在使用下面的命令来运行脚本。

casperjs url.js https://www.google.co.in/imghp?ie=UTF-8&hl=en&tab=wi&ei=ne6FUuvXIIiPrgeN-YGQDA&ved=0CAMQqi4oAg

url.js

代码语言:javascript
复制
var casper = require('casper').create({
pageSettings: {
    loadImages:  false,        
    loadPlugins: false         
},
verbose: true,
logLevel: "debug"
});
casper.echo("### Has URL: "+casper.cli.has(0));
casper.echo("### URL: "+casper.cli.get(0));
casper.run();

以及上面脚本的输出

代码语言:javascript
复制
C:\casperjs>casperjs custom.js https://www.google.
co.in/imghp?ie=UTF-8&hl=en&tab=wi&ei=ne6FUuvXIIiPrgeN-YGQDA&ved=0CAMQqi4oAg | cl
ip
### Has URL: true
### Store URL: https://www.google.co.in/imghp?ie=UTF-8
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: https://www.google.co.in/imghp?ie=UTF-8, HTTP GET

[debug] [phantom] Navigation requested: url=https://www.google.co.in/imghp?ie=UT
F-8, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "https://www.google.co.in/imghp?ie=UTF-8"
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/2 https://www.google.co.in/imghp?ie=UTF-8 (HTT
P 200)
### Got Url: https://www.google.co.in/imghp?ie=UTF-8 Data, Processing...
[info] [phantom] Step anonymous 2/2: done in 908ms.
[info] [phantom] Done 2 steps in 912ms
'hl' is not recognized as an internal or external command,
operable program or batch file.
'tab' is not recognized as an internal or external command,
operable program or batch file.
'ei' is not recognized as an internal or external command,
operable program or batch file.
'ved' is not recognized as an internal or external command,
operable program or batch file.

C:\casperjs>

实际上,它分裂了&符号后面的url,请给我一些解决方案,让我知道如果我做错了什么。

EN

回答 1

Stack Overflow用户

发布于 2013-11-15 17:21:05

这很可能是因为命令提示错误地解释了输入。

运行以下操作应该有效:

代码语言:javascript
复制
casperjs url.js "https://www.google.co.in/imghp?ie=UTF-8&hl=en&tab=wi&ei=ne6FUuvXIIiPrgeN-YGQDA&ved=0CAMQqi4oAg"
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19998472

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档