![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Lightweight HTML/XML extraction: links, forms, and sitemap URLs. More...
Include dependency graph for n_html.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | N_FORM_FIELD |
| a single form field (input, select, textarea, button) More... | |
| struct | N_HTML_FORM |
| a parsed HTML form with its fields More... | |
Functions | |
| LIST * | n_html_extract_forms (const char *html, size_t len) |
| extract forms as a LIST of N_HTML_FORM*; free with n_html_forms_free | |
| LIST * | n_html_extract_js_urls (const char *js, size_t len) |
| extract URL/path tokens from JavaScript source (quoted string literals that look like an http(s) URL, a protocol-relative "//host" URL, or a "/" / "./" / "../" path; a "${...}" template is truncated to its static prefix), deduped, as a LIST of N_STR*; free with n_html_links_free. | |
| LIST * | n_html_extract_links (const char *html, size_t len) |
| extract link URLs (a/href, form/action, img/src, script/src, link/href, iframe/src) as a LIST of N_STR*; free with n_html_links_free | |
| LIST * | n_html_extract_scripts (const char *html, size_t len) |
| extract the inline <script> bodies (those without a src attribute) from an HTML document as a LIST of N_STR*; free with n_html_links_free. | |
| void | n_html_forms_free (LIST **forms) |
| free a list returned by n_html_extract_forms | |
| void | n_html_links_free (LIST **links) |
| free a list returned by n_html_extract_links or n_sitemap_extract_urls | |
| N_STR * | n_html_to_text (const char *html, size_t len) |
| render HTML to readable plain text: drop tags, skip script/style, decode common entities, collapse whitespace, and line-break block elements; returns a new N_STR (free with free_nstr) or NULL | |
| LIST * | n_sitemap_extract_urls (const char *xml, size_t len) |
| extract <loc> URLs from a sitemap.xml as a LIST of N_STR*; free with n_html_links_free | |
Lightweight HTML/XML extraction: links, forms, and sitemap URLs.
A small, dependency-free tag scanner (not a full HTML parser) that pulls the link, form, and sitemap surface out of a document for a web crawler. It is tolerant of malformed markup and never executes anything.
Definition in file n_html.h.
| struct N_FORM_FIELD |
a single form field (input, select, textarea, button)
Collaboration diagram for N_FORM_FIELD:| struct N_HTML_FORM |
Collaboration diagram for N_HTML_FORM:| Data Fields | ||
|---|---|---|
| char * | action | action attribute (may be "" for self) |
| char * | enctype | lower-case enctype, default "application/x-www-form-urlencoded" |
| LIST * | fields | list of N_FORM_FIELD* |
| char * | method | upper-case method, default "GET" |
| LIST * n_html_extract_forms | ( | const char * | html, |
| size_t | len | ||
| ) |
extract forms as a LIST of N_HTML_FORM*; free with n_html_forms_free
Definition at line 392 of file n_html.c.
References _n_form_field_free(), _n_html_attr_lookup(), _n_html_form_free(), _n_html_scan_tags(), _n_html_strdup_upper(), _n_html_strndup(), _n_html_strndup_lower(), N_HTML_FORM::action, N_HTML_TAG_::closing, N_HTML_FORM::enctype, N_HTML_FORM::fields, list_destroy(), list_foreach, list_push(), Malloc, MAX_LIST_ITEMS, N_HTML_FORM::method, N_FORM_FIELD::name, N_HTML_TAG_::name, new_generic_list(), N_FORM_FIELD::required, N_FORM_FIELD::type, and N_FORM_FIELD::value.
Referenced by test_empty_and_null(), test_enctype(), and test_forms().
Here is the call graph for this function:
Here is the caller graph for this function:| LIST * n_html_extract_js_urls | ( | const char * | js, |
| size_t | len | ||
| ) |
extract URL/path tokens from JavaScript source (quoted string literals that look like an http(s) URL, a protocol-relative "//host" URL, or a "/" / "./" / "../" path; a "${...}" template is truncated to its static prefix), deduped, as a LIST of N_STR*; free with n_html_links_free.
Recovers fetch()/XHR/route endpoints a static link scan misses.
Definition at line 915 of file n_html.c.
References _n_html_push_js_url(), MAX_LIST_ITEMS, and new_generic_list().
Referenced by test_js_urls(), and test_scripts().
Here is the call graph for this function:
Here is the caller graph for this function:| LIST * n_html_extract_links | ( | const char * | html, |
| size_t | len | ||
| ) |
extract link URLs (a/href, form/action, img/src, script/src, link/href, iframe/src) as a LIST of N_STR*; free with n_html_links_free
Definition at line 360 of file n_html.c.
References _n_html_attr_lookup(), _n_html_push_link(), _n_html_scan_tags(), N_HTML_TAG_::closing, list_destroy(), list_foreach, MAX_LIST_ITEMS, N_HTML_TAG_::name, and new_generic_list().
Referenced by test_empty_and_null(), and test_links().
Here is the call graph for this function:
Here is the caller graph for this function:| LIST * n_html_extract_scripts | ( | const char * | html, |
| size_t | len | ||
| ) |
extract the inline <script> bodies (those without a src attribute) from an HTML document as a LIST of N_STR*; free with n_html_links_free.
Feed each to n_html_extract_js_urls to mine inline endpoints.
Definition at line 941 of file n_html.c.
References _n_html_find_ci(), char_to_nstr_ex(), free_nstr_ptr(), list_push(), MAX_LIST_ITEMS, and new_generic_list().
Referenced by test_scripts().
Here is the call graph for this function:
Here is the caller graph for this function:| void n_html_forms_free | ( | LIST ** | forms | ) |
free a list returned by n_html_extract_forms
Definition at line 984 of file n_html.c.
References list_destroy().
Referenced by test_empty_and_null(), test_enctype(), and test_forms().
Here is the call graph for this function:
Here is the caller graph for this function:| void n_html_links_free | ( | LIST ** | links | ) |
free a list returned by n_html_extract_links or n_sitemap_extract_urls
Definition at line 979 of file n_html.c.
References list_destroy().
Referenced by test_empty_and_null(), test_js_urls(), test_links(), test_scripts(), and test_sitemap().
Here is the call graph for this function:
Here is the caller graph for this function:| N_STR * n_html_to_text | ( | const char * | html, |
| size_t | len | ||
| ) |
render HTML to readable plain text: drop tags, skip script/style, decode common entities, collapse whitespace, and line-break block elements; returns a new N_STR (free with free_nstr) or NULL
Definition at line 627 of file n_html.c.
References _n_html_block_kind(), _n_html_entities, _n_html_flush(), _n_html_lc(), _n_html_put_cp(), _n_html_put_str(), char_to_nstr_ex(), Free, LOG_ERR, Malloc, and n_log.
Referenced by test_to_text().
Here is the call graph for this function:
Here is the caller graph for this function:| LIST * n_sitemap_extract_urls | ( | const char * | xml, |
| size_t | len | ||
| ) |
extract <loc> URLs from a sitemap.xml as a LIST of N_STR*; free with n_html_links_free
Definition at line 456 of file n_html.c.
References _n_html_strndup(), char_to_nstr(), Free, free_nstr_ptr(), list_push(), MAX_LIST_ITEMS, and new_generic_list().
Referenced by test_empty_and_null(), and test_sitemap().
Here is the call graph for this function:
Here is the caller graph for this function: