我将构建一个接口,通过phpquery从另一个网页获取数据。但有验证码图像,我无法获取验证码图像。
我也不能打印phpquery
的输出这里是重定向图像的代码
phpQuery::$debug = true;
$result = phpQuery::newDocumentFile($url);
echo $result;
foreach(pq('.whoContentTable') as $tag) {
foreach(pq($tag)->find('div.LBD_CaptchaImage') as $td) {
print $td;
代码输出:
Found: div.podContent, comparing with matchClasses()
Found: div.LBD_CaptchaDiv, comparing with matchClasses()
Found: div.LBD_CaptchaImage, comparing with matchClasses()
Found: div.LBD_CaptchaIcons, comparing with matchClasses()
Found: div#whoisverify_ctl00_cphcontent_ctlcaptcha_SoundPlaceholder.LBD_placeholder, comparing with matchClasses()
Found: input#ctl00_cphContent_btnVerifyCode.btnVerifyCode.WhoisMainSprite[name="ctl00$cphContent$btnVerifyCode"], comparing with matchClasses()
如何从页面获得输出内容?
您正在尝试获取目标网站的HTML内容吗?如果是,试试file_get_contents()
:
echo file_get_contents("http://urlOfWebsite.com");
您可以将函数的输出保存到一个变量中,并解析HTML以获得所需的元素。
文档:http://php.net/manual/en/function.file-get-contents.php