我想从以下代码中获取 IMG SRC 标签:
<pod title="Scientific name" scanner="Data" id="ScientificName:SpeciesData" position="200" error="false" numsubpods="1">
<subpod title="">
<plaintext>Canis lupus familiaris</plaintext>
<img src="http://www4a.wolframalpha.com/Calculate/MSP/MSP17941cd1c5fi21h72ac2000057i1ae7gc4986gdf?MSPStoreType=image/gif&s=44" alt="Canis lupus familiaris" title="Canis lupus familiaris" width="139" height="18"/>
</subpod>
</pod>
我知道如何获取明文信息,但如何获取 img src 信息?这是我必须获取明文信息的内容:
<?php
if(isset($_POST['q'])){
include 'WolframAlphaEngine.php';
$engine = new WolframAlphaEngine( 'APP-ID' );
$resp = $engine->getResults("$q");
$pod = $resp->getPods();
$pod1 = $pod[1];
foreach($pod1->getSubpods() as $subpod){
if($subpod->plaintext){
$plaintext = $subpod->plaintext;
break;
}
}
$result = substr($plaintext, 0,strlen($plaintext)-3);
echo "$plaintext";
}
?>
它不是抓取 A 元素的 href 属性的副本,因为我无法在 Godaddy 主机上使用 DOM。我以前试过。