HTML文章からテキスト部分のみを抜き出すプログラム例です。 用意したファイルは、コンパイルして実行ファイルとして利用が可能な他、宣言されているクラス(CHtml2Txt)を用いて他のソフトにも組み込むことが可能です。
実行時の引数は以下のようになります。
Gami[62]% html2txt USAGE: html2txt htmlfile [-disp] [-link] [-out textfile] [-url baseurl] option: -disp output to display (default .txt file). -link output link[ref url and image] -out htmlfile output filename -url set base URL Gami[63]% |
コンパイル: |
Gami[488]% g++ -o exp1 html2txt.cpp common.cpp exp1.cpp |
例題(exp1.cpp) |
01: #include <stdio.h> 02: #include "html2txt.h" 03: 04: int main(int argc,char* argv[]) 05: { 06: CHtml2Txt h2t(argc,argv); 07: if(h2t.ReadCode()) { 08: if(h2t.Convert()) 09: h2t.WriteCode(); 10: } 11: return 0; 12: } |