我有一个简单的代码,可以执行一些xpath查询并将结果返回给变量。到目前为止效果很好。
$url = 'https://www.example.com.com/test';
$dom = new DOMDocument('1.0');
@$dom->loadHTMLFile($url);
$xpath = new DomXpath($dom);
$tprice = $xpath->query('//tr/td/span/a[not(contains(text(),"eBay")) and not(contains(text(),"TEST"))]/../../../td[contains(@class, "os-total-col")]');
$seller = $xpath->query('//td/span/a[not(contains(text(),"eBay")) and not(contains(text(),"TEST"))]');
foreach($seller as $item) {
$item->removeAttribute("href");
}
$vk = $dom->saveXML($seller[0]);
$tp = $dom->saveXML($tprice[0]);
#mysql into a column ....
我还得到了一个数组,其中填充了一些这样的网址:
Array
(
[0] => Array
(
[0] => https://www.mydomain1.com/test
)
[1] => Array
(
[0] => https://www.mydomain2.com/test
)
[2] => Array
(
[0] => https://www.mydomain3.com/test
)
[3] => Array
(
[0] => https://www.mydomain4.com/test
)
[4] => Array
(
[0] => https://www.mydomain5.com/test
)
)
现在,我想为数组中的每个URL执行xpath查询/函数。我在stackoverflow和google上搜索了此问题,但找不到任何解决方案。可能是因为我不知道该“问题”的正确搜索词组。
你们有一些技巧或解决方案吗?