Extract text, title, description and language from HTML

html_text_content(html)

Arguments

html

Raw HTML as a single string.

Value

A list with `text` (cleaned, lowercased), `title`, `description` and `lang`. Missing elements are `NA_character_`; `text` is `""` when nothing could be extracted.

See also

[page_signals()], which uses this to decide whether a page is classifiable.

Examples

html <- "<html lang='en'><head><title>Example</title>
  <meta name='description' content='A demo page'>
  <script>ignored()</script></head>
  <body><p>Hello   World</p><style>p{}</style></body></html>"
html_text_content(html)
#> $text
#> [1] "hello world"
#> 
#> $title
#> [1] "Example"
#> 
#> $description
#> [1] "A demo page"
#> 
#> $lang
#> [1] "en"
#>