* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * 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
*
***************************************************************************/
+/* <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>
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));
}
CURL *curl;
HTMLSTREAMPARSER *hsp;
- if (argc != 2) {
+ if(argc != 2) {
printf("Usage: %s URL\n", argv[0]);
return EXIT_FAILURE;
}