Ogo*_*ofo 10 javascript login phantomjs casperjs
我最近尝试登录网站,迫使我接受cookie.我正在使用phantomJs和casperJs.我写了一个应该处理登录的小脚本,但它将我重定向到一个告诉我必须接受cookie的网站.电子邮件和密码只是占位符.
我想登录的网站是https://de.buyvip.com/.但是我需要点击按钮Anmelden mit Amazon才能登录我的亚马逊帐户.其他登录表单不起作用.(这导致这个长网址,我只是从我的浏览器复制它)
有人能帮我吗?
这是脚本:
var casper = require("casper").create()
var fs = require('fs');
var page = "https://www.amazon.de/ap/signin?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&pageId=quarterdeckde&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&clientContext=280-1158662-4507036&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&marketPlaceId=A38GABX06X24K&openid.assoc_handle=quarterdeckde&openid.return_to=https%3A%2F%2Fde.buyvip.com%2Fsignin&openid.pape.max_auth_age=0&siteState=http%3A%2F%2Fde.buyvip.com%2Fhomepage%3Fhash%3DM";
phantom.cookiesEnabled = true;
casper.start(page, function()
{
console.log("started");
this.fill('form#ap_signin_form', {
'email' : 'myMail',
'password' : 'myPass'
}, true);
});
casper.then(function()
{
fs.write("test.html", this.getHTML(), "w");
});
casper.run();
Run Code Online (Sandbox Code Playgroud)
小智 24
也许过了一会儿,但这就是答案:
casper.userAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
Run Code Online (Sandbox Code Playgroud)
由于亚马逊不喜欢默认的casper的用户代理,因为我的情况:"Mozilla/5.0(Macintosh; Intel Mac OS X)AppleWebKit/534.34(KHTML,像Gecko)CasperJS/1.0.2 + Phantomjs/1.7 .0 Safari/534.34"
| 归档时间: |
|
| 查看次数: |
9759 次 |
| 最近记录: |