我正在尋找firefox/firebug插件(或任何脫機工具都可以)來顯示真實文本/標記的比率。用於在html中顯示文本/代碼比例的工具
有一些在線工具,如http://www.seochat.com/seo-tools/code-to-text-ratio/和這個Firefox插件:https://addons.mozilla.org/en-US/firefox/addon/150366/(這也是在線的)。
我正在尋找firefox/firebug插件(或任何脫機工具都可以)來顯示真實文本/標記的比率。用於在html中顯示文本/代碼比例的工具
有一些在線工具,如http://www.seochat.com/seo-tools/code-to-text-ratio/和這個Firefox插件:https://addons.mozilla.org/en-US/firefox/addon/150366/(這也是在線的)。
我在PHP中做了一個小劇本,主要部分是:
$toparse = "htmltext";
$toparse = preg_replace('/(<script.*?>.*?<\/script>|<style.*?>.*?<\/style>|<.*?>|\r|\n|\t)/ms', '', $toparse);
$toparse = preg_replace('/ +/ms', ' ', $toparse);
$textlen = strlen($toparse);
有在這之後一些計算。
該正則表達式可以更短,但它的工作原理。唯一的要求是配對<
和>
。
$ (URL=www.google.com; echo "scale=2;"`lynx -nolist -dump $URL | wc -c`/`curl -silent $URL | wc -c` | bc)
.06
儘管在links
的input
S上好的HTML呈現偏斜的統計了一下。
Here's一個工具,我建這個文本到HTML的比例:
有些痛苦小(1次點擊)會更好。我說我正在使用Windows嗎? :) – Vili 2010-09-07 14:42:50