[英]how to find element in html using php?
I am trying to find an element in html document using php. 我正在尝试使用php在html文档中找到一个元素。
include_once('simple_html_dom.php');
$handle = fopen("exercise/Exercise.php", "r");
$file = fread($handle ,8192);
$handle = file_get_html('exercise/Exercise.php');
if (!empty($handle)) {
$ret = $handle->find('div[id=abc]');
}
but I have no idea What to do with $ret
now? 但我不知道现在如何处理$ret
? or even check has it found <div id="abc">
or not?is this even the right way I don't know because I am not very good at php? 甚至没有检查是否找到<div id="abc">
?这是否是我不知道的正确方法,因为我不太擅长php?
Edit that question is way to vast for me understand. 编辑该问题对我来说是一个广阔的途径。
它应该是
$handle->find('div[id=abc]', 0);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.