Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用Goutte登录Amazon SellerCentral_Php_Amazon_Goutte - Fatal编程技术网

Php 如何使用Goutte登录Amazon SellerCentral

Php 如何使用Goutte登录Amazon SellerCentral,php,amazon,goutte,Php,Amazon,Goutte,有没有办法使用Goutte登录卖家中心? 我尝试了这个,但它一直说密码错误(我手动尝试,效果很好): 谢谢想想看,我不能用痛风,它太有限了 将phantomjs与casperjs一起使用。使用Goutte登录 require_once 'vendor/autoload.php'; use Goutte\Client; $client = new Client(); $client->setHeader('User-Agent', "Mozilla/5.0 (Macintosh; Int

有没有办法使用Goutte登录卖家中心? 我尝试了这个,但它一直说密码错误(我手动尝试,效果很好):


谢谢

想想看,我不能用痛风,它太有限了

将phantomjs与casperjs一起使用。

使用Goutte登录

require_once 'vendor/autoload.php';

use Goutte\Client;

$client = new Client();
$client->setHeader('User-Agent', "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:57.0) Gecko/20100101 Firefox/57.0");
$url = 'https://sellercentral.amazon.in/';

$crawler = $client->request('GET',$url );

$form = $crawler->selectButton('signInSubmit')->form();

$crawler = $client->submit($form, array('email' => 'your_email', 'password' => 'password'));

echo $crawler->html();
使用phantomjs登录

var steps = [];
var testindex = 0;
var loadInProgress = false;//This is set to true when a page is still loading

/*********SETTINGS*********************/
var webPage = require('webpage');
var page = webPage.create();
page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:57.0) Gecko/20100101 Firefox/57.0';
page.settings.javascriptEnabled = true;
page.settings.loadImages = true;//Script is much faster with this field set to false
phantom.cookiesEnabled = true;
phantom.javascriptEnabled = true;
/*********SETTINGS END*****************/

console.log('All settings loaded, start with execution');
page.onConsoleMessage = function (msg) {
    console.log(msg);
};
/**********DEFINE STEPS THAT FANTOM SHOULD DO***********************/
steps = [

    //Step 1 - Open https://sellercentral.amazon.in/
    function () {
        console.log('Step 1 - Open https://sellercentral.amazon.in/');
        page.open("https://sellercentral.amazon.in/", function (status) {

        });
    },

    //Step 2 - Enter Login details and submit form
    function () {
        console.log('Step 2 - Enter Login details and submit form');
        page.evaluate(function () {
            document.getElementById("ap_email").value = "YOUR_EMAIL_ID";
            document.getElementById("ap_password").value = "YOUR_PASSWORD";
            document.forms['signIn'].submit();
        });
    },


    //Step 2 - Final Step save page as html file. 
    function () {
        console.log("Step 3 - Final step");
        var fs = require('fs');
        var result = page.evaluate(function () {
            return document.querySelectorAll("html")[0].outerHTML;
        });
        fs.write('AmazonSellercentral.html', result, 'w');
    },
];
/**********END STEPS THAT FANTOM SHOULD DO***********************/

//Execute steps one by one
interval = setInterval(executeRequestsStepByStep, 50);

function executeRequestsStepByStep() {
    if (loadInProgress == false && typeof steps[testindex] == "function") {
        //console.log("step " + (testindex + 1));
        steps[testindex]();
        testindex++;
    }
    if (typeof steps[testindex] != "function") {
        console.log("test complete!");
        phantom.exit();
    }
}

/**
 * These listeners are very important in order to phantom work properly. Using these listeners, we control loadInProgress marker which controls, weather a page is fully loaded.
 * Without this, we will get content of the page, even a page is not fully loaded.
 */
page.onLoadStarted = function () {
    loadInProgress = true;
    console.log('Loading started');
};
page.onLoadFinished = function () {
    loadInProgress = false;
    console.log('Loading finished');
};
page.onConsoleMessage = function (msg) {
    console.log(msg);
};

你知道如何通过php phantom js完成同样的工作吗
var steps = [];
var testindex = 0;
var loadInProgress = false;//This is set to true when a page is still loading

/*********SETTINGS*********************/
var webPage = require('webpage');
var page = webPage.create();
page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:57.0) Gecko/20100101 Firefox/57.0';
page.settings.javascriptEnabled = true;
page.settings.loadImages = true;//Script is much faster with this field set to false
phantom.cookiesEnabled = true;
phantom.javascriptEnabled = true;
/*********SETTINGS END*****************/

console.log('All settings loaded, start with execution');
page.onConsoleMessage = function (msg) {
    console.log(msg);
};
/**********DEFINE STEPS THAT FANTOM SHOULD DO***********************/
steps = [

    //Step 1 - Open https://sellercentral.amazon.in/
    function () {
        console.log('Step 1 - Open https://sellercentral.amazon.in/');
        page.open("https://sellercentral.amazon.in/", function (status) {

        });
    },

    //Step 2 - Enter Login details and submit form
    function () {
        console.log('Step 2 - Enter Login details and submit form');
        page.evaluate(function () {
            document.getElementById("ap_email").value = "YOUR_EMAIL_ID";
            document.getElementById("ap_password").value = "YOUR_PASSWORD";
            document.forms['signIn'].submit();
        });
    },


    //Step 2 - Final Step save page as html file. 
    function () {
        console.log("Step 3 - Final step");
        var fs = require('fs');
        var result = page.evaluate(function () {
            return document.querySelectorAll("html")[0].outerHTML;
        });
        fs.write('AmazonSellercentral.html', result, 'w');
    },
];
/**********END STEPS THAT FANTOM SHOULD DO***********************/

//Execute steps one by one
interval = setInterval(executeRequestsStepByStep, 50);

function executeRequestsStepByStep() {
    if (loadInProgress == false && typeof steps[testindex] == "function") {
        //console.log("step " + (testindex + 1));
        steps[testindex]();
        testindex++;
    }
    if (typeof steps[testindex] != "function") {
        console.log("test complete!");
        phantom.exit();
    }
}

/**
 * These listeners are very important in order to phantom work properly. Using these listeners, we control loadInProgress marker which controls, weather a page is fully loaded.
 * Without this, we will get content of the page, even a page is not fully loaded.
 */
page.onLoadStarted = function () {
    loadInProgress = true;
    console.log('Loading started');
};
page.onLoadFinished = function () {
    loadInProgress = false;
    console.log('Loading finished');
};
page.onConsoleMessage = function (msg) {
    console.log(msg);
};