Created
June 6, 2012 15:26
-
-
Save gusy/2882626 to your computer and use it in GitHub Desktop.
scrapping cope output podcast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$checkin_url='http://eurocopa.cope.es/Eurocopa2012/eurocope/audios/especial-eurocopa'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $checkin_url); | |
curl_setopt($ch, CURLOPT_HEADER, true); | |
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true); | |
$result=curl_exec($ch); | |
#echo $result; | |
$info=array(); | |
$pattern_lat="/titulo_audio\">(.*)<\/span/"; | |
preg_match_all($pattern_lat,$result, $matches); | |
$titles=$matches[1]; | |
$pattern_lat="/descripcion_audio\">(.*<\/p)/"; | |
preg_match_all($pattern_lat,$result, $matches); | |
$descriptions=$matches[1]; | |
$pattern_lat="/download-file\.jsp\?url=(http.*\.mp3)/"; | |
preg_match_all($pattern_lat,$result, $matches); | |
$files=$matches[1]; | |
curl_close($ch); | |
header('Content-type: text/xml'); | |
//CONSTRUCT RSS FEED HEADERS | |
$output = '<rss version="2.0">'; | |
$output .= '<channel>'; | |
$output .= '<title>Cope eurocopa no oficial</title>'; | |
$output .= '<description>He creado este podcast que enlaza archivos de la web de la eurocopa de cope, al no encontrar ninguna fuente de podcast. Contiene los programas especiales de las 15 y de las 20.30, así como otros cortes</description>'; | |
$output .= '<link>http://www.dondejuega.es/</link>'; | |
$output .= '<copyright>Supongo que de cadena cope, esto es sólo una lista de enlaces para seguidores</copyright>'; | |
//BODY OF RSS FEED | |
for($i=0;$i<sizeof($files);$i++){ | |
$output .= '<item>'; | |
$output .= '<title><![CDATA['.$titles[$i].']]></title>'; | |
$desc=strip_tags($descriptions[$i]); | |
$output .= '<description><![CDATA['.$desc.']]></description>'; | |
$output .= '<link>'.$files[$i].'</link>'; | |
$output .= '<enclosure url="'.$files[$i].'" length="0" type="audio/mpeg"/>'; //URL: FULL FILE PATH LENGTH: IN BYTES | |
$output .= '</item> '; | |
} | |
//CLOSE RSS FEED | |
$output .= '</channel>'; | |
$output .= '</rss>'; | |
//SEND COMPLETE RSS FEED TO BROWSER | |
echo($output); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment