このjQueryはページをスクラップするスクリプトを呼び出しますjson配列をjQueryに返します。ただし、場合によっては、cURLスクリプトによってキャプチャチャレンジページにリダイレクトされます(クラススクリプトのcURLを参照)。
cURLページが(目的のページではなく)キャプチャであると判断したら、キャプチャをユーザーにリダイレクトするにはどうすればよいですか?
キャプチャ画像とフォームのアクションパラメータと隠しフィールドを抽出し、ユーザーがフォームを提出できるようにフォームを再作成するだけですか?
jQuery("#myDiv a").click
(
function()
{
jQuery("#loader").show();
var result="";
jQuery.ajax
({
contentType: "application/json; charset=utf-8",
dataType: "json",
url: getPage.php,
success: function(data)
{
if(data["captcha"])
{
//need to load the captcha page for the user to complete
return;
}
}
});
});
//Contents of getPage.php
class loadPageCurl {
function loadPage($url, $headonly = TRUE ){
$agents = "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, $agents);
curl_setopt($ch, CURLOPT_URL, $url);
$curlResp = curl_exec($ch);
curl_close($ch);
//check to see if captcha or regular page and process accordingly
if(//page is captcha)
{
//Redirect the html stream to the user for captcha completion
}
else
{
return $curlResp;
}
}
回答:
回答№1は0http://api.jquery.com/jQuery.get/ 助けなければならない。
$.get("ajax/test.html", function(data) {
$(".result").html(data);
alert("Load was performed.");
});
ファイルから内容を読み込んでdivなどに入れることができます。
if(//page is captcha)
{
$.get("captcha.html", function(data) {
$(".captchaDiv").html(data);
});
}
これはあなたの問題を解決するかもしれません。