![](/img/trans.png)
[英]PHP: How to find and extract an element with src attribute in html (from url)
[英]how to find element in html 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]');
}
但我不知道現在如何處理$ret
? 甚至沒有檢查是否找到<div id="abc">
?這是否是我不知道的正確方法,因為我不太擅長php?
編輯該問題對我來說是一個廣闊的途徑。
它應該是
$handle->find('div[id=abc]', 0);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.