Comment obtenir le lien "thesrc" de la balise iframe avec SimpleHTMLDOM?SimpleHTMLDOM - Obtenir iframe src link
La source de la page je veux les données:
<div class="ui-tab-pane" data-role="panel" id="feedback">
<iframe scrolling="no" frameborder="0" marginwidth="0" marginheight="0"
width="100%" height="200"
thesrc="//feedback.aliexpress.com/display/productEvaluation.html?productId=32795263337&ownerMemberId=228319068&companyId=237873399&memberType=seller&startValidDate=&i18n=true"></iframe>
</div>
donc j'ai essayé:
<?php
include_once('simple_html_dom.php');
$html = file_get_html('https://www.aliexpress.com/item/Global-Version-Xiaomi-Redmi-Note-4-Mobile-Phone-3GB-RAM-32GB-ROM-Snapdragon-625-Octa-Core/32795263337.html');
$dom = new DOMDocument();
$dom->loadHTML($html);
$xpath = new DOMXpath($dom);
foreach ($xpath->query("//div[#class='ui-tab-pane']") as $node){
echo $node->getElementsByTagName('iframe')[0]->getAttribute("thesrc");
echo $node->getElementsByTagName('div')[0]->nodeValue;
}
?>
Il ne retourne rien. Qu'est-ce que je fais mal?
solution Grand et il fonctionne sans faille! Merci :) – Jack
Excellent! Heureux je pourrais aider – delboy1978uk
@Jack Cela obtiendra tout 'iframe' avec dans le' DOM'. Si c'est ce que vous voulez, c'est la solution parfaite. –