[英]How to find a specific value with Simple HTML DOM Parser
我只需要獲取“ since”的值,而是獲取具有相同類名的所有值。
$html = file_get_html("http://www.transfermarkt.co.uk/scottish-premiership/verletztespieler/wettbewerb/SC1/plus/1");
foreach ($html->find('.zentriert') as $element){
echo $element->plaintext ."\n";
}
運行代碼后的結果
從此直至
28
2016年12月27日2017年2月24日
33
2016年12月24日2017年2月28日
25
2017年1月31日2017年2月28日
19
....
我使用此代碼獲取了要在SINCE列中執行相同操作的玩家的名稱
foreach ($html->find('.hauptlink') as $element) {
$player_name = trim($element->plaintext);
echo $player_name ."\n";
}
與其按類查找,不如按列索引查找。
foreach ($html->find('.items td:nth-child(6)') as $element){
echo $element->plaintext ."\n";
}
$tdElements = $html->find('.items td.links+td.zentriert');
foreach($tdElements as $td){
echo $element->plaintext ."\n";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.