2014-09-05 81 views
0

请帮我改一下我的代码选择器。用php和ganon解析html

我尝试从http://www.plati.ru/asp/seller.asp?id_s=119777

页得到sellen名称这是必须AMEDIA,但我不能得到它。

这是我的代码

$result = curl_exec($ch); 
curl_close($ch); 
$html = str_get_dom($result); 

foreach ($html('table tr td tr td') as $element) { 
    $seller_name = $element->getPlainText(); 
} 
+0

也许这将是:body table tbody tr td table tbody tr td? – 2014-09-05 13:29:10

回答

0

你可以尝试以下方法,让我知道,如果你还有什么困难,

include "ganon.php"; 
$shopUrl = "http://www.plati.ru/asp/seller.asp?id_s=119777"; 
$html = file_get_dom($shopUrl); 
echo $html('table',9)->getPlainText(); 
+0

谢谢,你很喜欢 – bigjoy10 2014-09-05 14:19:27

+0

它是我的快乐朋友。快乐的编码 – Pundit 2014-09-05 14:21:29

0

可以使用DomDocument这样的代码来获取TD值:

<?php 
    header('Content-Type: text/html; charset=utf-8'); 

    $DOM = new DOMDocument; 
    @$DOM->loadHTMLFile('http://www.plati.ru/asp/seller.asp?id_s=119777'); 

    $tables = $DOM->getElementsByTagName('table');//->item(10); 
    $table = $tables->item(9); 
    $cells = $table->getElementsByTagName('td'); 
    $cell = $cells->item(0); 
    echo $cell->textContent; 
?> 

拆分$cell->textContent使用spa CES。