diff options
Diffstat (limited to 'docs/examples/href_extractor.c')
-rw-r--r-- | docs/examples/href_extractor.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/docs/examples/href_extractor.c b/docs/examples/href_extractor.c index c11325d2..16f50c0e 100644 --- a/docs/examples/href_extractor.c +++ b/docs/examples/href_extractor.c @@ -5,11 +5,11 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. + * are also available at https://curl.haxx.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is @@ -20,13 +20,13 @@ * ***************************************************************************/ +/* <DESC> + * Uses the "Streaming HTML parser" to extract the href pieces in a streaming + * manner from a downloaded HTML. + * </DESC> + */ /* - * This example uses the "Streaming HTML parser" to extract the href pieces in - * a streaming manner from a downloaded HTML. Kindly donated by MichaĆ - * Kowalczyk. - * - * The parser is found at - * http://code.google.com/p/htmlstreamparser/ + * The HTML parser is found at http://code.google.com/p/htmlstreamparser/ */ #include <stdio.h> @@ -38,11 +38,11 @@ static size_t write_callback(void *buffer, size_t size, size_t nmemb, void *hsp) { size_t realsize = size * nmemb, p; - for (p = 0; p < realsize; p++) { + for(p = 0; p < realsize; p++) { html_parser_char_parse(hsp, ((char *)buffer)[p]); - if (html_parser_cmp_tag(hsp, "a", 1)) - if (html_parser_cmp_attr(hsp, "href", 4)) - if (html_parser_is_in(hsp, HTML_VALUE_ENDED)) { + if(html_parser_cmp_tag(hsp, "a", 1)) + if(html_parser_cmp_attr(hsp, "href", 4)) + if(html_parser_is_in(hsp, HTML_VALUE_ENDED)) { html_parser_val(hsp)[html_parser_val_length(hsp)] = '\0'; printf("%s\n", html_parser_val(hsp)); } @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) CURL *curl; HTMLSTREAMPARSER *hsp; - if (argc != 2) { + if(argc != 2) { printf("Usage: %s URL\n", argv[0]); return EXIT_FAILURE; } |