Amazon sellercentral通过PHP和Curl登录

Amazon sellercentral通过PHP和Curl登录,php,curl,cookies,web-scraping,amazonsellercentral,Php,Curl,Cookies,Web Scraping,Amazonsellercentral,我在登录亚马逊卖家中心帐户后进行网络抓取,但在执行代码时,它总是返回一个错误 “有个问题 输入您的电子邮件或手机号码“ 我已经检查了cookie文件,cookies正在其中保存。根据需要设置标题。谁能告诉我我缺少什么 我看到很多帖子建议使用PhantomJS+CasperJS,但我没有太多时间学习这两个js。所以请帮我解决这个问题 $email = $username; // initial login page which redirects to correct si

我在登录亚马逊卖家中心帐户后进行网络抓取,但在执行代码时,它总是返回一个错误

“有个问题 输入您的电子邮件或手机号码“

我已经检查了cookie文件,cookies正在其中保存。根据需要设置标题。谁能告诉我我缺少什么

我看到很多帖子建议使用PhantomJS+CasperJS,但我没有太多时间学习这两个js。所以请帮我解决这个问题

    $email    = $username;

    // initial login page which redirects to correct sign in page, sets some cookies
    $URL = "https://sellercentral.amazon.com/gp/homepage.html?";

    $ch  = curl_init();

    curl_setopt($ch, CURLOPT_URL, $URL);
    curl_setopt($ch, CURLOPT_COOKIEJAR, '/var/www/html/amazoncookie.txt');
    curl_setopt($ch, CURLOPT_COOKIEFILE, '/var/www/html/amazoncookie.txt');
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 10);
    //curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_STDERR,  fopen('php://stdout', 'w'));
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    $page = curl_exec($ch);

    // try to find the actual login form
    if (!preg_match('/<form .*?<\/form>/is', $page, $form)) {
        die('Failed to find log in form!');
    }

    $form = $form[0];

    // find the action of the login form
    if (!preg_match('/action=(?:\'|")?([^\s\'">]+)/i', $form, $action)) {
        die('Failed to find login form url');
    }

    $URL2 = $action[1]; // this is our new post url

    // find all hidden fields which we need to send with our login, this includes security tokens
    $count = preg_match_all('/<input type="hidden"\s*name="([^"]*)"\s*value="([^"]*)"/i', $form, $hiddenFields);

    $postFields = array();

    // turn the hidden fields into an array
    for ($i = 0; $i < $count; ++$i) {
        $postFields[$hiddenFields[1][$i]] = $hiddenFields[2][$i];
    }

    // add our login values
    $postFields['username'] = $email;
    $postFields['password'] = $password;

    $post = '';

    // convert to string, this won't work as an array, form will not accept multipart/form-data, only application/x-www-form-urlencoded
    foreach($postFields as $key => $value) {
        $post .= $key . '=' . urlencode($value) . '&';
    }

    $post = substr($post, 0, -1);

    // set additional curl options using our previous options
    curl_setopt($ch, CURLOPT_URL, $URL2);
    curl_setopt($ch, CURLOPT_REFERER, $URL);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

    $page = curl_exec($ch); // make request
    print_r($page);
    return $ch;
$email=$username;
//初始登录页面重定向到正确的登录页面,设置一些cookie
$URL=”https://sellercentral.amazon.com/gp/homepage.html?";
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$URL);
curl_setopt($ch,CURLOPT_COOKIEJAR,'/var/www/html/amazoncookie.txt');
curl_setopt($ch,CURLOPT_COOKIEFILE,'/var/www/html/amazoncookie.txt');
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0(windowsnt 6.1;WOW64;rv:35.0)Gecko/20100101 Firefox/35.0');
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_头,10);
//curl_setopt($ch,CURLOPT_VERBOSE,true);
卷曲设置($ch,卷曲设置,fopen($ch)php://stdout","w"),;
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
$page=curl\u exec($ch);
//尝试查找实际的登录表单
如果(!preg_匹配()/