initial commit
This commit is contained in:
commit
ad82598214
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
|
@ -0,0 +1,37 @@
|
||||||
|
javascript: (function()
|
||||||
|
{
|
||||||
|
var map = {
|
||||||
|
"www.mediapart.fr": "https://www.mediapart.fr/articles/feed",
|
||||||
|
"www.lemonde.fr": "https://www.lemonde.fr/rss/une.xml"
|
||||||
|
};
|
||||||
|
|
||||||
|
var host = window.location.host;
|
||||||
|
var rssurl = map[window.location.host];
|
||||||
|
|
||||||
|
if (!rssurl)
|
||||||
|
{
|
||||||
|
alert("unknown newspaper");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fetch(rssurl)
|
||||||
|
.then(response => 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
|
@ -0,0 +1,61 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<title>Revue de presse</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: helvetica, sans-serif;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<base target="_blank">
|
||||||
|
<link rel="icon" type="image/png" href="1F4F0_color.png" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Revue de presse</h1>
|
||||||
|
<h2>Quotidiens</h2>
|
||||||
|
<p>
|
||||||
|
<a href="https://mediapart.fr">Mediapart</a>
|
||||||
|
- <a href="./mediapart.php">Edition du jour en version texte</a><br>
|
||||||
|
<a href="https://lesjours.fr">Les jours</a><br>
|
||||||
|
<a href="https://reporterre.net/">Reporterre</a><br>
|
||||||
|
<a href="https://basta.media">Basta!</a><br>
|
||||||
|
<a href="https://rebellyon.info">Rebellyon</a><br>
|
||||||
|
<a href="https://www.lemonde.fr/">Le Monde</a>
|
||||||
|
- <a href="https://journal.lemonde.fr/">Journal</a>
|
||||||
|
- <a href="https://nouveau.europresse.com/Pdf/Edition?sourceCode=LM_P">Europress</a>
|
||||||
|
</p>
|
||||||
|
<h2>Investigation</h2>
|
||||||
|
<p>
|
||||||
|
<a href="https://disclose.ngo">Disclose</a>
|
||||||
|
</p>
|
||||||
|
<h2>Analyse</h2>
|
||||||
|
<p>
|
||||||
|
<a href="https://www.revue-ballast.fr/">Ballast</a><br>
|
||||||
|
<a href="https://www.monde-diplomatique.fr">Le Monde diplomatique</a><br>
|
||||||
|
<a href="https://www.politis.fr">Politis</a>
|
||||||
|
- <a href="https://www.politis.fr/boutique/magazines-unite/#forward">Lire en ligne</a><br>
|
||||||
|
<a href="https://www.alternatives-economiques.fr">Alternatives économiques</a><br>
|
||||||
|
<a href="https://cqfd-journal.org">CQFD</a><br>
|
||||||
|
<a href="https://lundi.am">Lundi matin</a><br>
|
||||||
|
<a href="https://www.terrestres.org">Terrestres</a><br>
|
||||||
|
<a href="https://theconversation.com/fr">The conversation</a>
|
||||||
|
</p>
|
||||||
|
<h2>International</h2>
|
||||||
|
<p>
|
||||||
|
<a href="https://www.theguardian.com/europe">The Guardian</a><br>
|
||||||
|
<a href="https://www.nytimes.com/international/">The New York Times</a><br>
|
||||||
|
<a href="https://theintercept.com/">The intercept</a><br>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
<h2>Ressources</h2>
|
||||||
|
<p>
|
||||||
|
<a href="https://portail.basta.media">Revue de presse Basta</a><br>
|
||||||
|
<a href="https://www.bm-lyon.fr/les-offres-numeriques-de-la-bibliotheque/article/lire-la-presse-de-chez-vous">Europresse</a>
|
||||||
|
- <a href="https://nouveau.europresse.com/Pdf">Publications PDF</a><br>
|
||||||
|
<a href="https://www.cairn.info/">Cairn</a>
|
||||||
|
- <a href="https://www.cairn.info/revue-ecologie-et-politique.htm">Écologie & politique</a>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,133 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);*/
|
||||||
|
|
||||||
|
function cleantext( $node )
|
||||||
|
{
|
||||||
|
$content = $node->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 '<html><head><title>Mediapart - ' . $date . '</title></head><body>';
|
||||||
|
echo '<div><a download href="mediapart.txt">mediapart.txt</a></div>';
|
||||||
|
|
||||||
|
echo '<div>';
|
||||||
|
echo str_replace("\n", '<br>', $header) . '<br>' . str_replace("\n", '<br>', $result);
|
||||||
|
echo '</div>';
|
||||||
|
echo '</body></html>';
|
||||||
|
*/
|
||||||
|
|
||||||
|
$filename = 'mediapart' . str_replace(' ', '', $localedate) . '.txt';
|
||||||
|
header('Content-Type: application/text; charset=utf-8');
|
||||||
|
header('Content-Disposition: attachment; filename=' . $filename);
|
||||||
|
|
||||||
|
echo $header . "\n" . $result;
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in New Issue