simple_html_dom.php 的使用

來源:互聯網
上載者:User
simple_html_dom.php 可以說使用PHP處理 網頁, html 還可以.

不過, 與java 處理 不同的網頁編碼一樣, 對不同的編碼並沒有進行處理, 已進行了改進. 以下是使用方法:
(說明: 目前只修改為讀取 UTF8 或 gb2312 網頁.)

在 g/fw.php 中, 以下定義與 simple_html_dom 有關:

$MY_HTML_CONV = "utf8->gb"; // 這是讀取UTF8編碼時的設定.

$IS_CURL = true; // 使用 curl 讀取, 還是使用 file_get_contents讀取網頁.

$IS_CONV = true; // 使用 iconv() 還是使用 mb_convert_encoding 進行轉碼 <<-- 這與 simple_html_dom 無關

---------------------------------------------------------------------------------

注: 如果在一個函數中, 要讀取gb2312 的編碼, 而已經在 $MY_HTML_CONV 中指定的是讀取 UTF8 編碼的話, 要使用如下:

include('simplehtmldom/simple_html_dom.php');

// 讀取 GB2312 的網頁內容.
$GLOBALS['MY_HTML_CONV'] = null; // 注: 這行是為了修改在 g/fw.php 中已定義的值.
$html = str_get_html($ct);

---------------------------------------------------------------------------------

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.