我的问题需要帮助。 如何从网站上获取没有指定类或ID的span标记的值。
它的例子就在这里:
选择来源我只想获得
<p data-iceapc="3" data-iceapw="6"><span data-iceapw="2" style="font-size:25px; color:#98293D;">11am: 2-0-7 </span>
<span data-iceapw="2" style="font-size:25px; color:#98293D;">4pm: 7-2-3 </span>
<span data-iceapw="2" style="font-size:25px; color:#98293D;">9pm: _-_-_ </span></p>
我没有任何关于找到某人可能的元素的参考。
$dom = new DOMDocument();
$dom->loadHTML($Url);
$xpath = new DomXPath($dom);
$nodes = $xpath->query('//span[@style="font-size:25px; color:#98293D"]');
foreach ($nodes as $node) {
echo $node->nodeValue;
}
答案 0 :(得分:1)
这些是jQuery路径:
$("#content_box > article > div > p:nth-child(4) > span:nth-child(1)"); //value 1
$("#content_box > article > div > p:nth-child(4) > span:nth-child(3)"); // value 2
$("#content_box > article > div > p:nth-child(4) > span:nth-child(5)"); //value 3