From e60588e577f4544de41f3f093f9f2809a8234c10 Mon Sep 17 00:00:00 2001 From: Francisco Pessano Date: Fri, 16 Jul 2021 21:09:07 -0300 Subject: [PATCH] =?UTF-8?q?Soporte=20para=20Infobae=20a=C3=B1adido?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- control-files/00_ids_done.txt | 2 +- control-files/00_news_done.txt | 2 +- index.php | 2 + news_logic.php | 26 +++++++++- scripts/genbeta.js | 0 scripts/infobae.js | 87 ++++++++++++++++++++++++++++++++++ style.css | 6 +++ test-page.php | 31 ++++++++++++ 8 files changed, 152 insertions(+), 4 deletions(-) mode change 100644 => 100755 scripts/genbeta.js create mode 100755 scripts/infobae.js create mode 100755 test-page.php diff --git a/control-files/00_ids_done.txt b/control-files/00_ids_done.txt index c793025..301160a 100755 --- a/control-files/00_ids_done.txt +++ b/control-files/00_ids_done.txt @@ -1 +1 @@ -7 \ No newline at end of file +8 \ No newline at end of file diff --git a/control-files/00_news_done.txt b/control-files/00_news_done.txt index f57d3c3..084c758 100755 --- a/control-files/00_news_done.txt +++ b/control-files/00_news_done.txt @@ -1 +1 @@ - ./news/1.html ./news/2.html ./news/3.html ./news/4.html ./news/5.html ./news/6.html ./news/7.html \ No newline at end of file + ./news/1.html ./news/2.html ./news/3.html ./news/4.html ./news/5.html ./news/6.html ./news/7.html ./news/8.html \ No newline at end of file diff --git a/index.php b/index.php index e247959..665b149 100755 --- a/index.php +++ b/index.php @@ -40,6 +40,7 @@ $title = $news[1]; $frist_p = $news[2]; $icon = $news[3]; + $source = $news[4]; echo " @@ -48,6 +49,7 @@

$title

$frist_p

+
$source
"; diff --git a/news_logic.php b/news_logic.php index c780a21..614d073 100755 --- a/news_logic.php +++ b/news_logic.php @@ -1,5 +1,7 @@ ', '', $second_cut); break; + case $page === 'Infobae': + return $author = get_string_between($content, ',t.authors="', '",'); + break; + default: return 0; break; @@ -87,12 +97,24 @@ function create_entry_in_DB($news_unique, $page, $author) { $inner_HTML = get_string_between($content, '
', '
') . ''; $frist_p = strip_tags(get_string_between($inner_HTML, '

', '

')); break; + + case $page === 'Infobae': + $title = get_string_between($content, '', '- Infobae'); + $pre_icon = get_string_between($content, '
', '
'); + $icon = get_string_between($pre_icon, '992w,', ' 1200w" '); + $inner_HTML = get_string_between($content, '
', '
') . ''; + $frist_p = get_string_between($content, ''); + break; default: echo 0; return 0; break; } + $title; + $icon; + $inner_HTML; + $frist_p; $insert_news = $mySQLconnect -> prepare('insert into noticias (title, content, icon_route, page_source, author, frist_paragraph) values (?, ?, ?, ?, ?, ?)'); @@ -119,7 +141,7 @@ function bring_the_news_back_home($actual_page, $news_per_page) { $frist_calc = $actual_page * $news_per_page; $second_calc = ($actual_page * $news_per_page) - $news_per_page; - $prepared_query = $mySQLconnect -> prepare("select id, title, frist_paragraph, icon_route from noticias where id < ? and id > ?"); + $prepared_query = $mySQLconnect -> prepare("select id, title, frist_paragraph, icon_route, page_source from noticias where id < ? and id > ?"); $prepared_query -> bindParam(1, $frist_calc, PDO::PARAM_INT); $prepared_query -> bindParam(2, $second_calc, PDO::PARAM_INT); //$prepared_query -> execute(array($actual_page * 10, $actual_page * 10 - 10)); diff --git a/scripts/genbeta.js b/scripts/genbeta.js old mode 100644 new mode 100755 diff --git a/scripts/infobae.js b/scripts/infobae.js new file mode 100755 index 0000000..24c5c3c --- /dev/null +++ b/scripts/infobae.js @@ -0,0 +1,87 @@ +//todo - Informacion de infobae + +title = document.getElementsByClassName('article-headline')[0]; +console.log(title); + +sub_title = document.getElementsByClassName('article-subheadline')[0]; +console.log(sub_title); + +content = document.getElementsByClassName('nd-body-article')[0]; +console.log(content); + +trash = [document.getElementsByClassName('infogram-embed')[0]]; +console.log(trash); + +paragraphs = document.querySelectorAll('.paragraph, .visual__image'); +console.log(paragraphs); + +infobae = document.getElementsByTagName('article')[0]; + + +//todo - Estructura del sitio web cliente + +all = document.getElementsByClassName('all')[0]; +console.log(all); + +//todo - Purificacion de la informacion + +for (let i = 0; i < paragraphs.length; i++) { + if (paragraphs[i].innerHTML == "SEGUIR LEYENDO:" || paragraphs[i].innerHTML == "SEGUIR LEYENDO" || paragraphs[i].innerHTML == "
") { + console.log("AAAAA"); + trash.push(paragraphs[i]) + + } + +} + +title.innerHTML = '' + +for (let i = 0; i < trash.length; i++) { + if (trash[i] !== undefined){ + trash[i].innerHTML = '' + trash[i].remove(); + } +} + +//todo - Copiar e insertar informacion en el sitio web cliente + +//! TITULO +all.appendChild(title); + +frist_p = document.createElement("P") +frist_p.innerText = sub_title.innerText + +//! PARRAFOS +paragraphsFragment = document.createDocumentFragment(); + +paragraphsFragment.appendChild(frist_p) + +for (let i = 0; i < paragraphs.length; i++) { + + if (paragraphs[i].className == "visual__image ") { + console.log("AAAA"); + + paragraphs[i].children[0].style.height = "auto" + paragraphs[i].children[0].style.width = "100%" + } + + console.log(paragraphs[i]); + paragraphsFragment.appendChild(paragraphs[i]) + +} + +article = document.createElement('article') + +article.appendChild(paragraphsFragment) + +all.appendChild(article) + +//todo - Eliminar informacion de infobae + +infobae.remove() + +//todo - Eliminar el script + +script = document.getElementById('script-estructurator'); + +script.remove() \ No newline at end of file diff --git a/style.css b/style.css index 2d4f9d9..db64d8f 100755 --- a/style.css +++ b/style.css @@ -80,6 +80,8 @@ header { margin-right: 2vw; width: calc(74vw - 150px - 6vw); margin-bottom: 2vh; + display: flex; + flex-direction: column; } .card h2 { @@ -113,3 +115,7 @@ header { color: #797979; } +.card .source { + align-self: flex-end; + flex-grow: 1; +} \ No newline at end of file diff --git a/test-page.php b/test-page.php new file mode 100755 index 0000000..9ad5a75 --- /dev/null +++ b/test-page.php @@ -0,0 +1,31 @@ + + + + +
+ + +

AllNews.com

+
+
+ +
+
+ + + +
+
+ +
+ Autor: | Pagina fuente: +
+ + + \ No newline at end of file