资 源 简 介
It is a lightweight, simple, low memory usage, non-verifying HTML stream parser.
Originally written for embedded devices.
Parsing HTML stream char by char.
Not building HTML tree.
Supports invalid HTML code.
Here are a simple C programs that illustrates how to use the parser API.
You can run all programs with this command (assuming a name of the program is "a.out"):
wget -O - -q "http://code.google.com" | ./a.out
This one prints a tags names not using buffer.
```
#include
#include
int main(void) {
char c, new_line = 1;
HTMLSTREAMPARSER *hsp = html_parser_init();
while ((c = getchar()) != EOF) {
html_parser_char_parse(hsp, c);
if (html_parser_is_in(hsp, HTML_NAME)) {
new_line = 1;
printf("%c", c);
} else if (new_line) {
new_line = 0;
printf("
");
}
}
html_parser_cleanup(hsp);