0
$page = $curl->post($baseUrl.'/submit.php', array('url'=>$address,'phase'=>'1','randkey'=>$randKey[0],'id'=>'c_1'));
$exp = explode('recaptcha_image',$page);

没有找到 id recaptcha_image 虽然如果我echo $page;将显示网页,甚至令人惊讶的是 recpatcha div(带有图像本身)。Curl 不应该为 recaptcha 加载图像,但是当我尝试找到 div 时,它不存在。有没有办法捕获recaptcha图像的url?

4

1 回答 1

3

您将需要使用像PHP Simple HTML DOM Parser这样的 HTML 解析器。这样的事情将起作用:

<?php
$page = $curl->post($baseUrl.'/submit.php', array('url'=>$address,'phase'=>'1','randkey'=>$randKey[0],'id'=>'c_1'));
$html->load($page);
$ret = $html->find('script[src^=http://api.recaptcha.net/]',0);
$src = $ret->src;
//I'm not sure how you get an url with your library, so this might or might not work
$page = $curl->get($src);
preg_match("%challenge\ :\ '([a-zA-Z0-9-_]*)',%", $page, $matches);
$img = "http://api.recaptcha.net/image?c=".$matches[1];
?>

这首先获取页面,将其解析为脚本 URL,然后打开该 URL 进行质询,然后将其附加到 URL 本身。图像将在$img变量中。

于 2010-04-06T03:35:33.343 回答