0

誰かがこれを手伝ってくれるといいですね。これは私がこれまでに持っているものです。これを実行してdomの内容をエコーすると、まだログインページが表示されます。しかし、私は自分が間違っていることを理解できません。

    $target_url = "https://secretsales.com/";
    $fields = array('email' => 'abc', 'password' => '123');
    $postFields = http_build_query($fields, '', '&');

    // make the cURL request to $target_url
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($ch, CURLOPT_URL, $target_url);
    curl_setopt($ch, CURLOPT_FAILONERROR, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $html = curl_exec($ch);

    // parse the html into a DOMDocument
    $dom = new DOMDocument();
    @$dom -> loadHTML($html);

    // grab all the on the page
    $xpath = new DOMXPath($dom);

    echo $dom->saveHTML();
4

1 に答える 1

0

これを追加:

curl_setopt ($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . "/tmp/cookies.txt");
curl_setopt ($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . "/tmp/cookies.txt");

これにより、Cookie が指定されたディレクトリに保存されるため、そのディレクトリを作成する必要がある場合があります。

于 2013-02-09T16:34:21.547 に答える