1
這裏是我的腳本,其中我提取三項藥名,通用名,類名。我在這裏的問題是,我成功地獲取藥物名稱單獨但通用名稱和類名稱來作爲字符串。如果您將運行該腳本,您會更好地瞭解我實際上想說什麼,我想要存儲通用名稱和類名稱是表中的單獨列。simplehtmldom解析腳本打破純文本數據
腳本
<?php
error_reporting(0);
//simple html dom file
require('simple_html_dom.php');
//target url
$html = file_get_html('http://www.drugs.com/condition/atrial-flutter.html?rest=1');
//crawl td columns
foreach($html->find('td') as $element)
{
//get drug name
$drug_name = $element->find('b');
foreach($drug_name as $drug_name)
{
echo "Drug Name:-".$drug_name;
foreach($element->find('span[class=small] a',2) as $t)
{
//get the inner HTML
$data = $t->plaintext;
echo $data;
}
echo "<br/>";
}
}
?>
提前
大,它的工作。 – user2960749 2014-10-09 07:05:21
@ user2960749 im很高興幫助 – Ghost 2014-10-09 07:06:29
@ user2960749:如果提出的解決方案對您有幫助,您應該*接受*。只需點擊帖子分數下方的小勾號即可。 – lxg 2014-10-13 09:12:38