https://agent.lionair.co.id/lionairagentsportal/CaptchaGenerator.aspxから画像キャプチャを取得したい。
わかりません。
しかし、https://agent.lionair.co.id/lionairagentsportal/default.aspx という URL で新しいタブを開くと、https://agent.lionair.co.id/lionairagentsportal/CaptchaGenerator.aspxを開くと、画像は次のようになります。示す。
https://agent.lionair.co.id/lionairagentsportal/CaptchaGenerator.aspxに興味があります。https://agent.lionair.co.id/lionairagentsportal/default.aspxをまだ開いているのに開けないのはなぜですか。
このコードを試しましたが、残念ながら失敗しました。画像はまだ表示されません。
<?php
//The curl_init() will initialize a new session and return a CURL handle.
//curl_exec($ch) This function should be called after you initialize a CURL session and all the options for the session are set. Its purpose is simply to execute the predefined CURL session (given by the ch).
//curl_setopt( $ch, option, value) Set an option for a CURL session identified by the ch parameter. option specifies which option to set, and value specifies the value for the option given.
$url = "https://agent.lionair.co.id/LionAirAgentsPortal/default.aspx"; // From URL to get webpage contents.
$cookie_file_path = "/opt/lampp/htdocs/curl-examples/cookieFolder/cook";
$ch = curl_init(); // Initialize a CURL session.
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Return Page contents.
curl_setopt($ch, CURLOPT_URL, $url); // Pass URL as parameter.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path); // Tempat menaruh cookies.
$html = curl_exec($ch); // grab URL and pass it to the variable.
$ch = curl_init(); // Initialize a CURL session.
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Return Page contents.
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE); // Karena keluarannya gambar, maka di- set binary = true.
curl_setopt($ch, CURLOPT_URL, "https://agent.lionair.co.id/LionAirAgentsPortal/CaptchaGenerator.aspx"); // Pass URL as parameter.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path); // Tempat cookies di mana cookies mana yang mau digunakan.
$gambar = curl_exec($ch); // grab URL and pass it to the variable.
curl_close($ch); // close curl resource, and free up system resources.
?>
<html>
<head>
</head>
<body>
<form action="https://agent.lionair.co.id/LionAirAgentsPortal/default.aspx" name="form1" method="post">
<label for="txtLoginName">Username: </label>
<input type="text" name="txtLoginName" />
<br/>
<label for="txtPassword">Password: </label>
<input type="password" name="txtPassword" />
<br/>
<img src="data:image/jpeg;base64,<?php echo $gambar; ?>" />
<br/>
<label for="CodeNumberTextBox">Captcha: </label>
<input type="text" name="CodeNumberTextBox" />
<br/>
<input type="submit" value="otentikasi" />
</form>
</body>