[ 'method' => "GET", 'header' => "Accept-language: en\nCookie: MPSESSID=" . $sessionid, ] ]; $context = stream_context_create($opts); $epub = new TPEpubCreator(); $epub->temp_folder = 'temp/'; $epub->epub_file = 'mediapart.epub'; $epub->title = 'Mediapart'; // 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"); foreach ($items as $item) { $title = $item->title; $category = $item->xpath('dc:subject')[0]; $author = $item->xpath('dc:creator')[0]; $summary = $item->description; $article = file_get_contents($item->link, false, $context); $doc = new DOMDocument(); $doc->loadHTML($article); $finder = new DomXPath($doc); // 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 = "\n*" . $aside->textContent . "*\n"; // todo keep h2 } $maintext = $finder->query('//div[contains(@class, "paywall-restricted-content")]'); $result = '
' . $author . '
'; $result .= '' . $item->pubDate . '
'; $result .= '' . $summary . '
'; // todo use html instead $result .= '