Esta web utiliza cookies para proporcionarte la mejor experiencia de navegación posible. Estas cookies son guardadas en tu navegador y cumplen funciones como reconocerte cuando regresas a esta web y ayudarnos a saber qué secciones de la web encuentras más interesantes y útiles.
EninSoft - recursos para programadores web > Eninsoft > php > Script para descargar al música automáticamente
Script para descargar al música automáticamente
- diciembre 7, 2018
- Categoría: php utilidades web
No hay comentarios
Importante: Esta información es para uso lúdico personal. En ningún caso se pretende dar conocimientos, consejos, formaciones, herramientas, ni soluciones técnicas de ámbito comercial ni profesional. Simplemente es información que se ha redactado en finalidad de recordatorio de ciertos proyectos realizados. Si usted no está seguro de la fiabilidad de la información, no cumple con sus expectativas o no es de su agrado, le ruego que abandone este sitio web. Para ver todas las exclusiones garantía y de responsabilidad acceda a la sección Aviso Legal.
Crear archivo php con el siguiente contenido y ejecutarlo.
php -f web-scraping.php
web-scraping.php
<?php header ('Content-type: text/html; charset=utf-8'); session_start(); ini_set('max_execution_time',0); ini_set("memory_limit","1024M"); set_time_limit(0); echo 'WEBSCRAPING http://musica1.planetazzz.net/<br>'; echo '<br><br>'; $password = 'WWW.PLANETAZZZ.COM'; $google_link = array(); $_link = array(); $source = 'http://musica1.planetazzz.net/post-sitemap7.xml'; $response = file_get_contents($source); $sitemap = new SimpleXMLElement($response); if ($sitemap == null) continue; // Get page from sitemaps foreach ($sitemap->url as $value){ $_link[] = array('page' => $value->loc, 'file' => null); } $i = 1; // Get PASTEZZZ link from Webpage foreach ($_link as $key=>$value){ $html = file_get_contents($value['page']); if ($html == null) continue; // new page album format -> has Descargar Álbum button preg_match('/a href="(.*)&url=(.*)" class="su-button su-button-style-default"(.*)Descargar Álbum/',$html, $result); if ($result != null) { if (strpos($result[2],'http://pastezzz.com/v1/p') !== false) $_link[$key]['file'] = $result[2]; }else{ // old page album format // Do in futur } $i++; // if ($i >= 20) break; } $i = 1; foreach ($_link as $value){ if ($value['file'] == null) continue; // Manual mode //echo 'PAGE: '.$value['page'].'<br>'; //echo '<form name="frm'.$i.'" id="frm'.$i.'" method="post" action="'.$value['file'].'">'; //echo '<input name="pass" type="hidden" value="'.$password.'" />'; //echo '<input name="validate" type="hidden" value="Enviar" />'; //echo '<input name="send" type="submit" value="SEND" />'; //echo '</form><br><br>'; $i++; // Automatic download with Google Drive $stream_options = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded'."\r\n", 'content' => http_build_query( array('pass' => $password, 'validate' => 'Enviar'))) ); $context = stream_context_create($stream_options); $html = file_get_contents($value['file'],false,$context); //print_r($html); preg_match('/name="urls" value="(.*)"/', $html, $result); if (!isset($result[1])) continue; $result = explode(',',$result[1]); //print_r($result); foreach ($result as $glink){ if (strpos($glink,'https://drive.google.com') !== false) array_push($google_link, array('glink' => $glink, 'page' => $value['page'])); } } echo '--- MUSIC FILES GOOGLE DRIVE<br>'; foreach ($google_link as $glink) echo $glink['glink'].'<br>'; echo '--- END'; ?>