过滤网页中的HTML标签C++代码
2015-03-28 14:16
357 查看
#include<iostream> #include<fstream> #include<string> #include<stdlib.h> using namespace std; int Filter(string infile,string outfile) { char character; bool text_state(true); //string infile,outfile; ifstream html; ofstream htmltext; //cout<<"The name of input file"<<endl; //cin>>infile; //cout<<"The name of output file"<<endl; //cin>>outfile; html.open(infile.c_str()); if(html.fail()) { cerr<<"Error opening input file\n"; exit(1); } htmltext.open(outfile.c_str()); html.get(character); while(!html.eof()) { if(text_state) { if(character=='<') text_state=false; else htmltext<<character; } else { if(character=='>') text_state=true; } html.get(character); } html.close(); htmltext.close(); return 0; } int main() { string infile,outfile; cout<<"The name of input file"<<endl; cin>>infile; cout<<"The name of output file"<<endl; cin>>outfile; Filter(infile,outfile); system("pause"); return 0; }
相关文章推荐
- 运用正则表达式在Asp中过滤Html标签代码的四种不同方法
- 网页内容的html标签补全和过滤的两种方法
- [C/C++]_[字符串处理]_[过滤出HTML标签的属性值]
- 网页内容的html标签补全和过滤的两种方法
- C++发送HTTP请求获取网页HTML代码
- phpcms数据源调用discuz贴子具体内容过滤html论坛discuz标签代码
- 网页HTML代码中Meta标签详解
- [C/C++]_[字符串处理]_[过滤出HTML标签的属性值]
- 在网页中显示带有标签的HTML代码
- 网页HTML代码中Meta标签详解
- PHP实现网页内容html标签补全和过滤的方法小结【2种方法】
- C++发送HTTP请求获取网页HTML代码
- 过滤代码中的html标签
- C++发送HTTP请求获取网页HTML代码
- java+Jsoup 正则过滤html网页标签【多线程数据采集之二】
- 网页HTML代码中Meta标签详解
- java+Jsoup 正则过滤html网页标签【多线程数据采集之二】
- 网页制作HTML基础标签代码大全
- asp.net正则表达式提取网页网址、标题、图片实例以及过滤所有HTML标签实例
- ASP.NET正则表达式提取网页网址、标题、图片实例以及过滤所有HTML标签实例