Compare commits
No commits in common. "ee0f2fe47c3b0b301cef31ba2282a303cefc2027" and "d951c87d729da18730b361173b25fda59ab330b7" have entirely different histories.
ee0f2fe47c
...
d951c87d72
25
epub.php
25
epub.php
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
function get_clean_html($node)
|
function get_clean_html($node)
|
||||||
{
|
{
|
||||||
// todo check words with "-" (like "sous-traitance")
|
|
||||||
$innerHTM = '';
|
$innerHTM = '';
|
||||||
foreach ($node->childNodes as $childNode){
|
foreach ($node->childNodes as $childNode){
|
||||||
$nodeHTML = $childNode->ownerDocument->saveHTML($childNode);
|
$nodeHTML = $childNode->ownerDocument->saveHTML($childNode);
|
||||||
|
@ -75,7 +74,6 @@
|
||||||
// articles accès libre
|
// articles accès libre
|
||||||
$nodes = $finder->query('//div[contains(@class, "news__body__center__article")]');
|
$nodes = $finder->query('//div[contains(@class, "news__body__center__article")]');
|
||||||
}
|
}
|
||||||
// todo add "boite noire"
|
|
||||||
|
|
||||||
if (!$nodes->length)
|
if (!$nodes->length)
|
||||||
{
|
{
|
||||||
|
@ -207,8 +205,8 @@
|
||||||
|
|
||||||
$epub = new TPEpubCreator();
|
$epub = new TPEpubCreator();
|
||||||
$epub->temp_folder = 'temp/';
|
$epub->temp_folder = 'temp/';
|
||||||
$epub->epub_file = 'epub/' . $pubname . 'cafeyn.epub';
|
$epub->epub_file = 'epub/' . $pubname . '.epub';
|
||||||
$epub->title = $pubname . ' Cafeyn - ' . $today ;
|
$epub->title = $pubname . ' ' . $today ;
|
||||||
|
|
||||||
$list = (array)$publication->articles;
|
$list = (array)$publication->articles;
|
||||||
$page = 1;
|
$page = 1;
|
||||||
|
@ -396,7 +394,7 @@
|
||||||
$xml = new SimpleXMLElement($feed);
|
$xml = new SimpleXMLElement($feed);
|
||||||
$items = $xml->xpath("/rss/channel/item");
|
$items = $xml->xpath("/rss/channel/item");
|
||||||
|
|
||||||
foreach (array_reverse($items) as $item)
|
foreach ($items as $item)
|
||||||
{
|
{
|
||||||
add_mp_article($item->link, $context, $epub);
|
add_mp_article($item->link, $context, $epub);
|
||||||
}
|
}
|
||||||
|
@ -412,29 +410,24 @@
|
||||||
$opts = [
|
$opts = [
|
||||||
'http' => [
|
'http' => [
|
||||||
'method' => "GET",
|
'method' => "GET",
|
||||||
//'header' => "Accept-language: en\nCookie: MPSESSID=" . $mp_sessionid, // todo?
|
//'header' => "Accept-language: en\nCookie: MPSESSID=" . $mp_sessionid, // todo
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$context = stream_context_create($opts);
|
$context = stream_context_create($opts);
|
||||||
|
|
||||||
|
// todo add cover!
|
||||||
|
|
||||||
$epub = new TPEpubCreator();
|
$epub = new TPEpubCreator();
|
||||||
$epub->temp_folder = 'temp/';
|
$epub->temp_folder = 'temp/';
|
||||||
$epub->epub_file = 'epub/politis' . $issuenb . '.epub';
|
$epub->epub_file = 'epub/politis' . $issuenb . '.epub';
|
||||||
$epub->title = 'Politis ' . $issuenb . ' - RSS ' . $today;
|
$epub->title = 'Politis ' . $issuenb . ' - RSS ' . $today;
|
||||||
|
|
||||||
// find cover
|
|
||||||
$issues = file_get_contents('https://www.politis.fr/boutique/magazines-unite/');
|
|
||||||
$doc = new DOMDocument();
|
|
||||||
$doc->loadHTML($issues);
|
|
||||||
$finder = new DomXPath($doc);
|
|
||||||
$cover = $finder->query('//img[contains(@src, "' . $issuenb . '_")]')->item(0)->getAttribute('src');
|
|
||||||
$epub->AddImage($cover, 'image/jpeg', true);
|
|
||||||
|
|
||||||
// load feeds
|
// load feeds
|
||||||
$feed = file_get_contents($feedurl);
|
$feed = file_get_contents($feedurl);
|
||||||
$xml = new SimpleXMLElement($feed);
|
$xml = new SimpleXMLElement($feed);
|
||||||
$items = $xml->xpath("/rss/channel/item");
|
$items = $xml->xpath("/rss/channel/item");
|
||||||
|
|
||||||
|
// reverse to respect timing
|
||||||
foreach (array_reverse($items) as $item)
|
foreach (array_reverse($items) as $item)
|
||||||
{
|
{
|
||||||
$url = $item->link;
|
$url = $item->link;
|
||||||
|
@ -504,7 +497,7 @@
|
||||||
write_epub($epub);
|
write_epub($epub);
|
||||||
}
|
}
|
||||||
|
|
||||||
// New York Times RSS
|
// New York Times
|
||||||
if (isset($_POST['nyt']) && $_POST['nyt'])
|
if (isset($_POST['nyt']) && $_POST['nyt'])
|
||||||
{
|
{
|
||||||
$feedurl = 'https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml';
|
$feedurl = 'https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml';
|
||||||
|
@ -526,7 +519,7 @@
|
||||||
$xml = new SimpleXMLElement($feed);
|
$xml = new SimpleXMLElement($feed);
|
||||||
$items = $xml->xpath("/rss/channel/item");
|
$items = $xml->xpath("/rss/channel/item");
|
||||||
|
|
||||||
foreach (array_reverse($items) as $item)
|
foreach ($items as $item)
|
||||||
{
|
{
|
||||||
$title = $item->title;
|
$title = $item->title;
|
||||||
$author = $item->xpath('dc:creator')[0];
|
$author = $item->xpath('dc:creator')[0];
|
||||||
|
|
Loading…
Reference in New Issue