2014-06-24 14:22:16 +02:00
|
|
|
|
|
|
|
<script type="text/x-red" data-template-name="html">
|
|
|
|
<div class="form-row">
|
2015-05-10 22:47:22 +02:00
|
|
|
<label for="node-input-tag"><i class="fa fa-filter"></i> <span data-i18n="html.label.select"></span></label>
|
2016-06-27 00:48:59 +02:00
|
|
|
<input type="text" id="node-input-tag" placeholder="h1">
|
2014-06-24 14:22:16 +02:00
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
2015-05-10 22:47:22 +02:00
|
|
|
<label for="node-input-ret"><i class="fa fa-sign-out"></i> <span data-i18n="html.label.output"></span></label>
|
2016-06-27 00:48:59 +02:00
|
|
|
<select id="node-input-ret" style="width:70%">
|
2015-05-28 00:07:31 +02:00
|
|
|
<option value="html" data-i18n="html.output.html"></option>
|
2015-12-19 13:44:11 +01:00
|
|
|
<option value="text" data-i18n="html.output.text"></option>
|
|
|
|
<option value="attr" data-i18n="html.output.attr"></option>
|
2014-06-24 14:22:16 +02:00
|
|
|
<!-- <option value="val">return the value from a form element</option> -->
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-as"> </label>
|
2016-06-27 00:48:59 +02:00
|
|
|
<select id="node-input-as" style="width:70%">
|
2015-05-28 00:07:31 +02:00
|
|
|
<option value="single" data-i18n="html.format.single"></option>
|
|
|
|
<option value="multi" data-i18n="html.format.multi"></option>
|
2014-06-24 14:22:16 +02:00
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<br/>
|
|
|
|
<div class="form-row">
|
2015-05-10 22:47:22 +02:00
|
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
2016-06-27 00:48:59 +02:00
|
|
|
<input type="text" id="node-input-name" style="width:70%" data-i18n="[placeholder]common.label.name">
|
2014-06-24 14:22:16 +02:00
|
|
|
</div>
|
2015-05-10 22:47:22 +02:00
|
|
|
<div class="form-tips"><span data-i18n="[html]html.tip"></span></div>
|
2014-06-24 14:22:16 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/x-red" data-help-name="html">
|
2016-02-12 14:16:28 +01:00
|
|
|
<p>Extracts elements from an html document held in <code>msg.payload</code> using a selector.</p>
|
2017-04-25 22:47:58 +02:00
|
|
|
<h3>Inputs</h3>
|
|
|
|
<dl class="message-properties">
|
|
|
|
<dt>payload <span class="property-type">string</span></dt>
|
|
|
|
<dd>the html string from which to extract elements.</dd>
|
|
|
|
<dt class="optional">select <span class="property-type">string</span></dt>
|
|
|
|
<dd>if not configured in the edit panel the selector can be set as a property of msg.</dd>
|
|
|
|
</dl>
|
|
|
|
<h3>Output</h3>
|
|
|
|
<dl class="message-properties">
|
|
|
|
<dt>payload <span class="property-type">array | strings</span></dt>
|
|
|
|
<dd>the result can be either a single message with a payload containing an array of the matched elements, or multiple
|
|
|
|
messages that each contain a matched element.</dd>
|
|
|
|
</dl>
|
|
|
|
<h3>Details</h3>
|
2016-10-12 18:53:27 +02:00
|
|
|
<p>The selector uses <a href="https://github.com/cheeriojs/cheerio/blob/master/Readme.md" target="_blank">Cheerio</a>
|
|
|
|
which uses the <a href="https://github.com/fb55/CSSselect#user-content-supported-selectors" target="_blank">CSS selector</a> syntax.</p>
|
2014-06-24 14:22:16 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
RED.nodes.registerType('html',{
|
|
|
|
category: 'function',
|
|
|
|
color:"#DEBD5C",
|
|
|
|
defaults: {
|
2015-02-10 17:55:50 +01:00
|
|
|
name: {value:""},
|
2014-06-24 14:22:16 +02:00
|
|
|
tag: {value:""},
|
|
|
|
ret: {value:"html"},
|
2015-02-10 17:55:50 +01:00
|
|
|
as: {value:"single"}
|
2014-06-24 14:22:16 +02:00
|
|
|
},
|
|
|
|
inputs:1,
|
|
|
|
outputs:1,
|
2016-06-12 23:37:38 +02:00
|
|
|
icon: "parser-html.png",
|
2014-06-24 14:22:16 +02:00
|
|
|
label: function() {
|
|
|
|
return this.name||this.tag||"html";
|
|
|
|
},
|
|
|
|
labelStyle: function() {
|
|
|
|
return this.name?"node_label_italic":"";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|