歡迎您光臨本站 註冊首頁

· simple_html_dom 使用教程雜誌閱讀

如何開始使用simple_html_dom解析html

admin @ 2020-03-30 reply:0
如何使用php html 解析

上傳類文件以後,有三種方式調用這個類:

從url中載入html文檔

從字元串中載入html文檔

從文件中載入html文檔

<?php
  // 新建一個Dom實例
  $html = new simple_html_dom();

  // 從url中載入
  $html->load_file('http://coctec.com/index.html');

  // 從字元串中載入
  $html->load('從字元串中載入html文檔演示');

  //從文件中載入 絕對路徑
  $html->load_file('test.html');
?>
如果從字元串載入html文檔,需要先從網路上下載。建議使用cURL來抓取html文檔並載入DOM中。

[admin via ] 如何開始使用simple_html_dom解析html已經有649次圍觀

http://coctec.com/magazine/show-post-item-8.html