From ad82598214a8a338d0f4c65a15bfdecc3e8c2d95 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Thu, 23 May 2024 13:59:38 +0200 Subject: [PATCH] initial commit --- 1F4F0_color.png | Bin 0 -> 3015 bytes daily.js | 37 ++++++++++++++ index.html | 61 ++++++++++++++++++++++ mediapart.php | 133 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 231 insertions(+) create mode 100644 1F4F0_color.png create mode 100644 daily.js create mode 100644 index.html create mode 100644 mediapart.php diff --git a/1F4F0_color.png b/1F4F0_color.png new file mode 100644 index 0000000000000000000000000000000000000000..94f15d2984b5e948ffec3cdcdfe9282fefc78357 GIT binary patch literal 3015 zcmcgudpJ~U7gvg0Bcj~WCn8Pf2*Yu|jhbZ47?C~4sN*18h+JX_36X9tBlmHcX{Ko^ zu~o*Ulaf+M8yVr#IVc&9FeCSC@Cp@ z-YY9BiwFe;`5o99)3J7HrB+%4n_ESBS$!RseU){uu>pnJsjRHLe*OCV{Je`7FPutDIC(P8-pc2*`9i#?Z-5fvF35fNT{_l~dcuT@pI zLPA20hlNonF$YYN$cSTG!(DMi5z*Pj1M(UUXWpU{$Zd_=n_v4&vATmIu^Z)biV43N?}#h@qOCZ%x(X-X9rDx&!j@ytH$TYa9}C&n+4d3d zbZ04>8Rt*d8{E7tVm^SZXFatyjc5H-f9O2jflr#Yr2yJ}287B-G;g@8pa zDLyB{BY~R~!vYg{yVfQf{X7{1y6EXLSl6$h#cU0XYm0eO>m&nSMM2H7Vi=2qlr(_; z&{n?QhO@h|#de-lN&3^NOMU~d|G_q}(NopGw4U>f7rZ<-*g>TvMV_p%Pm(T!2z|Wb)c8js46t{~MzOr;EViqc!pBekbY^0T5Pc?_5YM z87*LHJ96^IE?_MkP$;k~JpRu3Mi5INIpy+nK|KPc;QgdQa5+^DqGz+tl_Hp!&8q)c zNI;KVEjsEa3B^Zj_XVvrq=WqEFB)^aDGiCh5gl(+B#apkWIGMyo_Wmi6MTnQRy)o+oWLQ@}ZhId~<&zrWGGa`dasU}cPSa!-7 zb9jFcL+#4E5Y6Nut`LpnAa%s;noVbbXh|r8b#6~tO&ZV)r>w@3X2gyBK~f@ zD4w zKLQT3?wtzVcHa=0rL`?;(;8UsJC!sDe zQ45MS6s9i*MYlT3`vaOUx@LA3h{99e*Zn>j;(a0+sYjJ(a_?f%X}}0PMj*d1HA)5s z;O?et)oDOCJaGPj=a`l-i8PL|oP}i>N26Og25I_&Ay&>o7M*~qmka;E6Sx`C3_5}B z++yB*HY@HErXVNH#z~zOWeGhwQrju^u7uGoUEOUw*tNswt*ff(zbkpcG-$w<;~HOl zwVE=UgqBiz{VE~2%$>D=SA||s_|m<4!QCOvKu*w0)Q8!|#b0R7L6qn5rVm&U4JaDaw?XNHPNF1s)3Ei}QHPaI*=A+ev`peG_^X>K zU&`M-&fWm-DD&|k5Vv~mC}sT1?0Hgt`kM}xkgd{&VdJP0W`yl1r3`NlZt|Rq*c3n~ zzi7GBv`Dw{`tjmX^GKu2>P}CE$JM-#`lS^)F}O|ps6`X{81`I7 response.text()) + .then(xmlstring => { + const parser = new DOMParser(); + const xmldoc = parser.parseFromString(xmlstring, 'text/xml'); + var today = new Date; + + items = xmldoc.evaluate("/rss/channel/item", xmldoc); + while ((item = items.iterateNext())) + { + var itemdate = new Date(item.getElementsByTagName("pubDate")[0].textContent); + var itemlink = item.getElementsByTagName("link")[0].textContent; + if (itemdate.toDateString() == today.toDateString()) + { + console.log("will open " + itemlink); + window.open(itemlink, "_blank"); + } + } + }); + } +})(); \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..451cb90 --- /dev/null +++ b/index.html @@ -0,0 +1,61 @@ + + + + + + Revue de presse + + + + + +

Revue de presse

+

Quotidiens

+

+ Mediapart + - Edition du jour en version texte
+ Les jours
+ Reporterre
+ Basta!
+ Rebellyon
+ Le Monde + - Journal + - Europress +

+

Investigation

+

+ Disclose +

+

Analyse

+

+ Ballast
+ Le Monde diplomatique
+ Politis + - Lire en ligne
+ Alternatives économiques
+ CQFD
+ Lundi matin
+ Terrestres
+ The conversation +

+

International

+

+ The Guardian
+ The New York Times
+ The intercept
+ +

+

Ressources

+

+ Revue de presse Basta
+ Europresse + - Publications PDF
+ Cairn + - Écologie & politique +

+ + diff --git a/mediapart.php b/mediapart.php new file mode 100644 index 0000000..19b9fe3 --- /dev/null +++ b/mediapart.php @@ -0,0 +1,133 @@ +textContent; + $content = str_replace('Partager sur Facebook', '', $content); + $content = str_replace('Partager sur X (ex Twitter)', '', $content); + + $content = str_replace('Lire + tard', '', $content); + $content = str_replace('Offrir l’article', '', $content); + $content = str_replace(' PDF', '', $content); + $content = str_replace('Cette fonctionnalité est actuellement en maintenance.La génération de PDF reste disponible via la fonctionnalité «Imprimer».', '', $content); + + $content = str_replace("Fermer\n", '', $content); + $content = str_replace("Recommander\n", '', $content); + $content = str_replace("Commenter\n", '', $content); + + + $content = str_replace(' ', '', $content); + $content = str_replace("\n", "\n\n", $content); + for ($i = 0; $i < 15; $i++) + { + $content = str_replace("\n\n\n", "\n\n", $content); + } + + return $content; +} + +$sessionid = 'value of cookie MPSESSID'; +$feedurl = 'https://www.mediapart.fr/articles/feed'; +$opts = [ + 'http' => [ + 'method' => "GET", + 'header' => "Accept-language: en\nCookie: MPSESSID=" . $sessionid, + ] +]; +$context = stream_context_create($opts); + +// load feeds +$feed = file_get_contents($feedurl); +$xml = new SimpleXMLElement($feed); +$items = $xml->xpath("/rss/channel/item"); + +setlocale(LC_ALL, 'fr_FR.UTF8', 'fr_FR','fr','fr','fra','fr_FR@euro'); +$localedate = strftime("%A %d %B %Y"); + +$header = "Mediapart - " . $localedate . "\n\nSommaire:\n"; +$result = ''; + +foreach ($items as $item) +{ + if (str_starts_with($item->pubDate, date("D, j M Y"))) + { + $title = $item->title; + + // Add to content + $header .= '- ' . $title . "\n"; + + $article = file_get_contents($item->link, false, $context); + $doc = new DOMDocument(); + $doc->loadHTML($article); + $finder = new DomXPath($doc); + + $category = trim($finder->query('//p[@class="news__heading__top__kicker _default"]')->item(0)->textContent); + $summary = trim($finder->query('//p[@class="news__heading__top__intro margin-top:500"]')->item(0)->textContent); + $author = trim($finder->query('//a[@class="focus color:text-brand heading-product:100"]')->item(0)->textContent); + + // clean images + $figures = $finder->query('//figure'); + foreach ($figures as $figure) + { + $figure->parentNode->removeChild($figure); + } + + // clean "à lire aussi" and inline quotes + $asides = $finder->query('//aside'); + foreach ($asides as $aside) + { + $aside->parentNode->removeChild($aside); + } + + // improve section titles + $asides = $finder->query('//h2'); + foreach ($asides as $aside) + { + $aside->textContent = '*' . $aside->textContent . '*'; + } + + // Output + + // old: add header as one block + //$part1 = $finder->query('//div[@class="news__heading grid"]'); + //$result .= cleantext($part1->item(0)); + + $result .= "\n------\n\n"; + $result .= "Article : " . $item->title . "\n"; + $result .= 'Catégorie: ' . str_replace("\n", '', $category) . "\n"; + $result .= 'Auteur.ice : ' . $author . "\n"; + $result .= "\n"; + $result .= "Introduction :\n" . $summary . "\n"; + + // article main text + $maintext = $finder->query('//div[@class="news__body__center"]'); + $result .= cleantext($maintext->item(0)); + } + //break; +} + +// web version: + +/* +file_put_contents('mediapart.txt', $header . "\n" . $result); + +echo 'Mediapart - ' . $date . ''; +echo ''; + +echo '
'; +echo str_replace("\n", '
', $header) . '
' . str_replace("\n", '
', $result); +echo '
'; +echo ''; +*/ + +$filename = 'mediapart' . str_replace(' ', '', $localedate) . '.txt'; +header('Content-Type: application/text; charset=utf-8'); +header('Content-Disposition: attachment; filename=' . $filename); + +echo $header . "\n" . $result; + +?> \ No newline at end of file