From a2bdf984fc3088d789432b8778bc8cff9799a3ac Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Thu, 29 Aug 2024 18:26:08 +0200 Subject: [PATCH] Revert "add politis (rss)" This reverts commit a7a1095487700270b56b33c974f2638c30d53d53. --- epub.php | 109 ------------------------------------------------------- 1 file changed, 109 deletions(-) diff --git a/epub.php b/epub.php index 312580b..a7153eb 100644 --- a/epub.php +++ b/epub.php @@ -545,110 +545,6 @@ } write_epub($epub); } - - // Politis - if (isset($_POST['politis']) && $_POST['politis']) - { - // cookies? - /*$opts = [ - 'http' => [ - 'method' => "GET", - 'header' => "Accept-language: en\nCookie: MPSESSID=" . $mp_sessionid, - ] - ]; - $context = stream_context_create($opts);*/ - - $epub = new TPEpubCreator(); - $epub->temp_folder = 'temp/'; - $epub->epub_file = 'epub/politis.epub'; - $epub->title = 'Politis - RSS ' . $today; - - // load feeds - $feedurl = 'https://www.politis.fr/flux-rss-politis-fr/'; - $feed = file_get_contents($feedurl); - $xml = new SimpleXMLElement($feed); - $items = $xml->xpath("/rss/channel/item"); - - // toc-based to test - /* - action=get_sommaire - id_produit=310761 - nonce=89e48e1696 - https://www.politis.fr/wp-admin/admin-ajax.php - */ - - - foreach ($items as $item) - { - if (new DateTime($item->pubDate) < new DateTime('-7 days')) - { - continue; - } - // restrict to last week - $url = $item->link; - - $article = file_get_contents($url); //, false, $context); - $doc = new DOMDocument(); - $doc->loadHTML($article); - $finder = new DomXPath($doc); - - $title = $finder->query('//h1')->item(0)->textContent; - $author = $finder->query('//div[@class="auteur_date"]/span[@class="nom"]')->item(0)->textContent; - $date = $finder->query('//div[@class="auteur_date"]/span[@class="date"]')->item(0)->textContent; - $summary = $finder->query('//div[@class="extrait"]')->item(0)->textContent; - - // strip images - /*$toremove = $finder->query('//svg'); - foreach ($toremove as $elt) - { - $elt->parentNode->removeChild($elt); - } - $toremove = $finder->query('//figure'); - foreach ($toremove as $elt) - { - $elt->parentNode->removeChild($elt); - } - $toremove = $finder->query('//span[@class="screen-reader-only"]'); - foreach ($toremove as $elt) - { - $elt->parentNode->removeChild($elt); - }*/ - - $toremove = $finder->query('//script'); - foreach ($toremove as $elt) - { - $elt->parentNode->removeChild($elt); - } - - $result = '

' . $title . '

'; - $result .= '

' . $author . '

'; - $result .= '

' . $date . '

'; - $result .= '

' . $summary . '

'; - - $nodes = $finder->query('//main/section[@class="section_top" or @class="section_content"]'); - if (!$nodes->length) - { - echo 'warning: could not get content of "' . $title . '"
'; - } - else - { - // top - $node = $nodes->item(0); - $nodehtml = get_clean_html($node); - $result .= $nodehtml; - - // content - $node = $nodes->item(1); - $nodehtml = get_clean_html($node); - $result .= $nodehtml; - - $epub->AddPage($result, false, $title); - } - } - - write_epub($epub); - } - ?>

Generate epub

@@ -685,11 +581,6 @@ -

Politis

- - -
-

Admin