gpt4 book ai didi

javascript - PhantomJS/CasperJS 站点登录,PhantomJS 不接受 cookie

转载 作者:可可西里 更新时间:2023-11-01 02:30:31 25 4
gpt4 key购买 nike

我最近尝试登录一个强制我接受 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();

最佳答案

也许稍后,但这是答案:

casper.userAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');

cookie 失败是因为亚马逊不喜欢默认的 casper 用户代理,在我的例子中:“Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) CasperJS/1.0.2+ Phantomjs/1.7.0 Safari/534.34"

关于javascript - PhantomJS/CasperJS 站点登录,PhantomJS 不接受 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13492821/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com