• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Nur ein bestimmtes Element im Iframe

rewetuete

Neues Mitglied
Heyho,

ich bin noch ein Neuling in Sachen Webdesign und habe da mal eine Frage. Ich möchte nur ein bestimmtes HTML-Element "iframen" :D
D.h. Hier der Quellcode der Seite, den ich brauch:

HTML:
<p id="prices">   <a href="http://www.amazon.de/gp/offer-listing/B0017VFJWA/ref=as_li_ss_til?tag=dieins-21&camp=2906&creative=19474&linkCode=am1&creativeASIN=B0017VFJWA&adid=1TNR5A4GQDHS6FYXYWZJ&" target="_blank">Bester Preis <span class="price" style="text-decoration:underline;">EUR 90,00</span></a> <br /> oder     neu <span class="price">EUR 121,95</span> </p>

Das heisst ich möchte nur das Element "prices" einbinden. Der Preis kommt immer von Amazon.de. Deshalb möchte ich das auch per Iframe machen, sodass der Preis immer aktuell ist.
Wie gehts das? :D
 
Nur über HTML/CSS wird das wohl nicht umzusetzen sein.
Was du machen könntest, wäre ein PHP-Script zu verwenden, dass den Quelltext der Amazon-Seite ausließt, und dann nach dem Preis sucht und ihn ausgibt:
PHP:
<?php
  $amazon_content = file_get_contents("http:/amazon.de/produktXYZ");
  preg_match('/<p id="prices">.*<\/p>/', $amazon_content, $price); 
  echo $price[0];
?>

Dieses Script speicherst du zum Beispiel als 'price.php' ab und bindest es mit
PHP:
<?php
  include "http://deine_homepage.de/price.php";
?>
in die Seite ein

oder halt über ein Iframe
HTML:
<iframe src="http://deine_homepage.de/price.php" ... ></iframe>
 
Hey, vielen Dank!

Da hätte ich auch selber drauf kommen müssen! :D So wie du's beschreibst klappts auch perfekt nur jetzt ich hab ein anderes Problem.

Modifizierter Code:
PHP:
<?php
  $amazon_content = file_get_contents("http://www.amazon.de/Philips-HD-3610-50-Bierzapfanlage/dp/B0017VFJWA/ref=sr_1_1?ie=UTF8&qid=1315755736&sr=8-1");
  preg_match('/<div class="buying" id="priceBlock">.*<\/div>/', $amazon_content, $price); 
  echo $price[0];
?>

Code der Seite:
HTML:
<div class="buying" id="priceBlock">  <table class="product">    <tr>     <td class="priceBlockLabel">Unverb. Preisempf.:</td>     <td class="listprice">EUR 189,99 </td>   </tr>    <tr>     <td class="priceBlockLabelPrice"><b>Preis:</b></td>     <td><b class="priceLarge">EUR 121,95</b>      </td> </tr>    <tr>     <td class="priceBlockLabel">Sie sparen: </td>     <td class="price">EUR 68,04       (36%)     </td>   </tr>  <tr>   <td>&nbsp;</td>   <td>Alle Preisangaben inkl. MwSt.</td> </tr>  <tr style="height: 0px; line-height: 0px;"><td style="visibility: hidden;"/><td style="visibility: hidden;"><span style="line-height: 0px;">o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o</span></td></tr> </table> </div>

Jetzt klappt's aber plötzlich nicht mehr! Was mach ich nur falsch? :cry::mrgreen:
 
mmmh... scheinbar kann das ganze nur Zeilenweise gesucht werden..

Ist jetz zwar nen bisschen umständlich, aber was besseres fällt mir grad net ein, als das Tabellengerüst nachzustellen, und die einzelnen Textstellen in die jeweiligen Tabellenzellen zu schrieben:
PHP:
<?php
  $amazon_content = file_get_contents("http://www.amazon.de/Philips-HD-3610-50-Bierzapfanlage/dp/B0017VFJWA/ref=sr_1_1?ie=UTF8&qid=1315755736&sr=8-1");

  echo "<div>";
  echo " <table>";
  echo "  <tr>";
  echo "   <td>";
  preg_match('/<td class="priceBlockLabel">.*<\/td>/', $amazon_content, $price); 
  echo $price[0];
  echo "   </td>";
  echo "    <td>";
  preg_match('/<td class="listprice">.*<\/td>/', $amazon_content, $price); 
  echo $price[0];
  echo "   </td>";
  echo "  </tr>";
  echo "  <tr>";
  echo "   <td>";
  preg_match('/<td class="priceBlockLabelPrice">.*<\/td>/', $amazon_content, $price); 
  echo $price[0];
  echo "   </td>";

  /* etc... */
?>
 
Kann man nicht einfach irgendwie alle Leerzeichen herausfiltern und dann die andere Methoden wählen?
Trotzdem schonmal Danke :)
 
Ich hab's selbst gelöst! Juchuuh!! :D

Hier ist die Lösung:
PHP:
<?php
  $amazon_content = file_get_contents("http://www.amazon.de/Philips-HD-3610-50-Bierzapfanlage/dp/B0017VFJWA/ref=sr_1_1?ie=UTF8&qid=1315755736&sr=8-1");
  preg_match('/<div class="buying" id="priceBlock">.*<\/div>/msU', $amazon_content, $price); 
  echo $price[0];
?>
 
Zurück
Oben