从api代码获取特定标签

I want to get the IMG SRC tag from the following code:

<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>

I know how to get the plaintext information but how do I get the img src information? Here's what I have to get the plaintext information:

<?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";

}
?>

It's not a duplicate of Grabbing the href attribute of an A element because I can't use DOM on my Godaddy hosting. I've tried it before.

查看全部
duanjiuhong5843
duanjiuhong5843
2013/05/08 13:44
  • image
  • src
  • php
  • html
  • tags
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复