Skip to contents

Reads the headings, paragraphs and list items of a saved page, in order, when no selector for its main content is known.

Usage

read_html_blocks(path)

Arguments

path

Character. Path of the HTML file.

Value

A data.table with paragraph (order), block_type (tag), block_class (class attribute), block_in_table and text, or NULL if the file cannot be parsed.

Examples

f <- tempfile(fileext = ".html")
writeLines("<body><h1>Title</h1><p class='x'>Text.</p></body>", f)
read_html_blocks(f)
#>    paragraph block_type block_class block_in_table   text
#>        <int>     <char>      <char>         <lgcl> <char>
#> 1:         1         h1        <NA>          FALSE  Title
#> 2:         2          p           x          FALSE  Text.