我运行这个 PHP 代码以从 test1 获取一些代码。
<?php
libxml_use_internal_errors(true);
$doc = new DOMDocument();
$doc->loadHTMLFile("http://inviatapenet.gethost.ro/sop/test1.php");
$xpath = new DOMXpath($doc);
$elements = $xpath->query("//*[@type='button']/@onclick");
if (!is_null($elements)) {
foreach ($elements as $element) {
$nodes = $element->childNodes;
foreach ($nodes as $node) {
echo $node->nodeValue. "\n";
}
}
}
?>
结果是这样的
OnPlay('sop://broker.sopcast.com:3912/120704 cod ', ' eu - Nr.1 in tv ! ')
OnPlay('sop://broker.sopcast.com:3912/140601 cod ', ' eu - Nr.1 in tv ! ')
OnPlay('sop://broker.sopcast.com:3912/124589 cod ', ' eu - Nr.1 tv')
OnPlay('sop://broker.sopcast.com:3912/589994 cod ', ' eu - tv ')
OnPlay('sop://broker.sopcast.com:3912/ cod ', ' eu - tv ')
但我只需要所有这些数据:`sop://broker.sopcast.com:3912/140601
他们都是。
如何摆脱多余的文本或如何获取 (sop://broker.sopcast.com:3912/140601,sop://broker.sopcast.com:3912/120704)