dtgr3392 2017-02-07 03:14
浏览 96

PHP - 通过表单登录并抓取cookie

I'm trying to login to the following URL: pitangui.amazon.com

I have tried using cURL as well as libraries like https://barebonescms.com/documentation/ultimate_web_scraper_toolkit/

However, I'm getting the following error using the webscraper via Amazon:

Amazon Error

This is my PHP code:

<?php
    require_once "support/http.php";
    require_once "support/web_browser.php";
    require_once "support/simple_html_dom.php";

    $url = "https://pitangui.amazon.com";
    $web = new WebBrowser(array("extractforms" => true));
    $result = $web->Process($url);

    if (!$result["success"])  echo "Error retrieving URL.  " . $result["error"] . "
";
    else if ($result["response"]["code"] != 200)  echo "Error retrieving URL.  Server returned:  " . $result["response"]["code"] . " " . $result["response"]["meaning"] . "
";
    else
    {   

        $form = $result["forms"][0];

        $form->SetFormValue("email", "myemail@gmail.com");
        $form->SetFormValue("password", "mypass");

        $result2 = $form->GenerateFormRequest("signIn");

        $result = $web->Process($result2["url"], "auto", $result2["options"]);

        if (!$result["success"])  echo "Error retrieving URL.  " . $result["error"] . "
";
        else if ($result["response"]["code"] != 200)  echo "Error retrieving URL.  Server returned:  " . $result["response"]["code"] . " " . $result["response"]["meaning"] . "
";
        else
        {
            // Do something with the results page here...
            print_r($result);
        }
    }
?>

I'm first trying to get the login working, then I will grab the cookie via $_SERVER['Cookie']

  • 写回答

1条回答 默认 最新

  • douxiongzhen2126 2017-05-04 05:11
    关注

    add

    $form->SetFormValue("create","0");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测