TextFromHTML

Extract regular text from the given HTML.

python · Common Scripts

Details

IDTextFromHTML
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10116658
TagsUtility

README

Extract regular text from the given HTML

Script Data


Name Description
Script Type python3
Tags Utility
Cortex XSOAR Version 5.0.0

Inputs


Argument Name Description
html The HTML to strip tags from.
html_tag Specify the HTML tag to extract the text from within.
allow_body_fallback Allow using the input HTML as a fallback for the body, if no body tag is found. This only applies, if html_tag is set to body.
replace_line_breaks Replace `br` in `html` with linebreaks in the output.
trim_result Trim the extracted result. When set to true, leading and trailing whitespaces are removed and blocks of more than 3 consecutive whitespaces are collapsed to two.
output_to_context Store the extracted text in context.

Outputs


Path Description Type
TextFromHTML The Text extracted from the given HTML. string

Script Examples

Example command

!TextFromHTML html="<!DOCTYPE html><html><body><h1>This is heading 1</h1></body></html>"

Context Example

{}

Human Readable Output

This is heading 1

commonfields:
  id: TextFromHTML
  version: -1
name: TextFromHTML
script: ''
type: python
subtype: python3
tags:
- Utility
comment: Extract regular text from the given HTML.
enabled: true
args:
- name: html
  required: true
  default: true
  description: The HTML to strip tags from.
- name: html_tag
  default: true
  defaultValue: body
  description: Specify HTML tag to extract the text from within.
- name: allow_body_fallback
  default: true
  auto: PREDEFINED
  predefined:
  - "true"
  - "false"
  description: 'Allow using the input HTML as a fallback for the body, if no body tag is found. This only applies, if html_tag is set to body.'
  defaultValue: "false"
- name: replace_line_breaks
  default: true
  auto: PREDEFINED
  predefined:
  - "true"
  - "false"
  description: 'Replace `br` in `html` with linebreaks in the output.'
  defaultValue: "false"
- name: trim_result
  default: true
  auto: PREDEFINED
  predefined:
  - "true"
  - "false"
  description: 'Trim the extracted result. When set to true, leading and trailing whitespaces are removed and blocks of more than 3 consecutive whitespaces are collapsed to two.'
  defaultValue: "false"
- name: output_to_context
  description: Store the extracted text in context.
  default: true
  auto: PREDEFINED
  predefined:
  - "true"
  - "false"
  defaultValue: "false"
scripttarget: 0
fromversion: 5.0.0
dockerimage: demisto/python3:3.12.13.10116658
tests:
- TextFromHTML_test_playbook
contentitemexportablefields:
  contentitemfields:
    fromServerVersion: ''
runas: DBotWeakRole
outputs:
- contextPath: TextFromHTML
  description: The Text extracted from the given HTML.
  type: string