Streaming HTML parser 介绍
Streaming HTML parser 是一个 C 语言的 HTML 解析器。
示例代码
#include <stdio.h> #include <streamhtmlparser/htmlparser.h> int main(void) { unsigned int getchar_ret; htmlparser_ctx *parser = htmlparser_new(); while((getchar_ret = getchar()) != EOF) { char c = (char)getchar_ret; /* If we received a '$' character, we output the current tag and attribute * name to stdout. */ if (c == '$') { printf("[[ "); if (htmlparser_tag(parser)) printf("tag=%s ", htmlparser_tag(parser)); if (htmlparser_attr(parser)) printf("attr=%s ", htmlparser_attr(parser)); printf("]]"); /* If we read any other character, we pass it to the parser and echo it to * stdout. */ } else { htmlparser_parse_chr(parser, c); putchar(c); } } }
输入
输出
Streaming HTML parser 官网
http://code.google.com/p/streamhtmlparser/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。