我試圖在這個API中調用我的價格,這不是一個問題,但問題是價格有鏈接而不是普通文本,任何人都可以看到我做錯了什麼?Php解析總是有href
<?php
$x = file_get_contents("http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=authorized-key&trackingId=7000610&categoryId=7185&numItems=8&printers");
$xml = simplexml_load_string($x);
foreach($xml->categories->category->items->product as $item)
{
print '<div style="float: left; width: 120px; padding: 10px; overflow: auto; display: block;">';
print '<a rel="nofollow" onclick="javascript:_gaq.push([\'_trackPageview\', \'/outgoing/article_exit_link/789591\']);" href="'.$item->productOffersURL.'"><img src="'.$item->images->image[0]->sourceURL.'" width="100"></a>';
print '<img src="'.$item->rating->ratingImage[0]->sourceURL.'" width="91">';
print "<br/>".l($item->name, $item->productOffersURL, array(), NULL, NULL, TRUE);
//print "<br/>".l($item->shortDescription, $item->productOffersURL, array(), NULL, NULL, TRUE);
// this is where the prices are.
print "<br/>" .l($item->minPrice, $item->productOffersURL, array(), NULL, NULL, TRUE);
print "<br/>".l($item->maxPrice, $item->productOffersURL, array(), NULL, NULL, TRUE);
print '</div>';
}
?>
這是dom螢火蟲正在返回。
<div style="float: left; width: 120px; padding: 10px; overflow: auto; display: block;">
<a href="http://www.shopping.com/Canon-Canon-EOS-400D-Twin-Lens-Kit-Silver-Body-18-55mm-EF-75-300mm-f-4-5-6-Lens/prices~linkin_id-7000610" onclick="javascript:_gaq.push(['_trackPageview', '/outgoing/article_exit_link/789591']);" rel="nofollow"><img width="100" src="http://di1.shopping.com/images/pi/cf/86/d8/58898587-100x100-0-0.jpg?p=p2.48bc03c211719c7871ea&a=2&c=1&l=7000610&t=11062&r=1"></a>
<img width="91" src="http://img.shopping.com/sc/pr/sdc_stars_sm_4.5.gif"><br>
<a href="http://www.shopping.com/Canon-Canon-EOS-400D-Twin-Lens-Kit-Silver-Body-18-55mm-EF-75-300mm-f-4-5-6-Lens/prices~linkin_id-7000610">Canon EOS 400D/EOS Rebel XTi Digital Camera with 18-55mm and 75-300mm lenses</a><br>
<a href="http://www.shopping.com/Canon-Canon-EOS-400D-Twin-Lens-Kit-Silver-Body-18-55mm-EF-75-300mm-f-4-5-6-Lens/prices~linkin_id-7000610">598.00</a><br>
<a href="http://www.shopping.com/Canon-Canon-EOS-400D-Twin-Lens-Kit-Silver-Body-18-55mm-EF-75-300mm-f-4-5-6-Lens/prices~linkin_id-7000610">990.00</a>
</div>
與螢火蟲檢查,看看是否被列入他們在'' – fire
請出示HTML-DOM(瀏覽器 - >右鍵點擊 - >檢查元素) –
是的,他們是在它的圖像上的完整鏈接。 –