Browse Source

Исправления РИА и ТАСС #9

master
parent
commit
e68ad3e294
  1. 12
      news_parser.js

12
news_parser.js

@ -151,7 +151,7 @@
}
function ElementCheckerRia(a_Element) {
if (a_Element.dataset.type == 'article' || a_Element.dataset.type == 'banner' || a_Element.dataset.type == 'media') {
if (a_Element.dataset.type == 'article' || a_Element.dataset.type == 'banner' || a_Element.dataset.type == 'media' || a_Element.dataset.type == 'video') {
return false;
}
@ -206,7 +206,7 @@
parent.removeChild(a_Element);
}
function GetClearHtml(a_Element, a_OutTag, a_TextAlign, a_SubElementCheckerToRemove) {
function GetClearHtml(a_Element, a_OutTag, a_TextAlign, a_SubElementCheckerToRemove, a_ClearTextFunc, a_ElementIndex) {
let clear_element = a_Element.cloneNode(true);
let elements = clear_element.querySelectorAll('*');
@ -250,6 +250,9 @@
});
let result = TrimString(clear_element.innerHTML);
if (a_ClearTextFunc) {
result = a_ClearTextFunc(result, a_ElementIndex);
}
if (a_OutTag && a_TextAlign && TrimString(result).replace(' ', '') != '') {
result = '<' + a_OutTag + ' style = "text-align:' + a_TextAlign + ';">' + result + '</' + a_OutTag + '>';
}
@ -263,10 +266,7 @@
if (a_Element && CheckRegExp(GetElementClassName, 'Title_title.*', a_Element)) {
out_tag = 'h2';
}
let a_Content = GetClearHtml(a_Element, out_tag, a_TextAlign, a_SubElementCheckerToRemove)
if (a_ClearTextFunc) {
a_Content = a_ClearTextFunc(a_Content, a_ElementIndex);
}
let a_Content = GetClearHtml(a_Element, out_tag, a_TextAlign, a_SubElementCheckerToRemove, a_ClearTextFunc, a_ElementIndex);
if (a_Element && a_Element.dataset && a_Element.dataset.type == 'quote') {
a_Content = '<blockquote>' + a_Content + '</blockquote>';

Loading…
Cancel
Save