Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
RSS для megapo.st
<?php
$rand = rand(1, 999999);
$source = 'https://lenta.ru/rs'.'?'.$rand; //fix for cache
// http://manage.megapo.st 8 минута// 16 минута// 24 минута// 32 минута// 40 минута// 48 минута// 56 минута// 8 минута
$options = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n" .
"User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.".$rand.". (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10\r\n" // i.e. An iPad
)
);
$context = stream_context_create($options);
$GetRss = file_get_contents($source, false, $context);
// preg_match_all("/<lastBuildDate>(.*)<\/lastBuildDate>/", $GetRss, $lastBuildDate);
preg_match_all("/<pubDate>(.*)<\/pubDate>/", $GetRss, $RssPubDate);
foreach ($RssPubDate as $RssDate => $valueRssDate) {
}
// dump($valueRssDate,0,'valueRssDate');
$ToLinuxTimeRssDate = array();
foreach ($valueRssDate as $valueDate) {
$ToHis = date('r', strtotime($valueDate));
$ToLinuxTimeRssDate[] = strtotime($valueDate);
// dump($ToHis,0,'ToHis');
// dump($ToLinuxTimeRssDate,0,'ToLinuxTimeRssDate111');
}
$NewTimeRssDate = array();
$NewTimeRssDateGoodDate = array();
for ($i=0; $i < 9; $i++) {
$raznica = $ToLinuxTimeRssDate[$i] - $ToLinuxTimeRssDate[$i+1];
if ($raznica < 700) {
// echo 'есть лимит';
$ToLinuxTimeRssDate[$i] = $ToLinuxTimeRssDate[$i] + 800; // for example
}
// $NewTimeRssDate[] .= $ToLinuxTimeRssDate[$i];
$NewTimeRssDateGoodDate[] .= str_replace('+0200','+0300',date('r', $ToLinuxTimeRssDate[$i]+3600)); //fix for date timezone
}
// dump($NewTimeRssDateGoodDate,0,'NewTimeRssDateGoodDate');
for ($i=0; $i < 9; $i++) {
// preg_replace("/<pubDate>(.*)<\/pubDate>/", $NewTimeRssDateGoodDate[$i], $GetRss);
$GetRss = str_replace($valueRssDate[$i], $NewTimeRssDateGoodDate[$i], $GetRss);
}
// foreach ($lastBuildDate as $lastBuild => $lastBuildD) {
// }
// $GetRss = str_replace($lastBuildD[0], $NewTimeRssDateGoodDate[0], $GetRss);
// dump($GetRss,0,'GetRss');
echo $GetRss;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.