Foros del Web » Programando para Internet » PHP »

Extraer parte especifica de codigo

Estas en el tema de Extraer parte especifica de codigo en el foro de PHP en Foros del Web. Hola a todos Dentro del siguiente código necesito extraer una parte de él: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código Javascript : Ver original < script type = "text/javascript" ...
  #1 (permalink)  
Antiguo 17/07/2014, 13:08
Avatar de after  
Fecha de Ingreso: junio-2006
Ubicación: De marte
Mensajes: 791
Antigüedad: 18 años, 6 meses
Puntos: 10
Extraer parte especifica de codigo

Hola a todos

Dentro del siguiente código necesito extraer una parte de él:

Código Javascript:
Ver original
  1. <script type="text/javascript">_main('\/file\/d\/0Bya7uRIlM1kWN3g4cUZhNFpULWM', {'sid': '40fb345b33affb60','id': '0Bya7uRIlM1kWN3g4cUZhNFpULWM', 'email': '', 'title': 'Dexter.S07E01.HDTV.XviD-MGD.avi', 'description': '', 'mimetype': 'video\/x-msvideo', 'fileExtension': 'avi', 'mediaType': 'video', 'revisions': [{"tags":[],"creatorDisplayName":"leonardo da vinci","pinned":true,"filename":"Dexter.S07E01.HDTV.XviD-MGD.avi","downloadUrl":"https://docs.google.com/uc?id=0Bya7uRIlM1kWN3g4cUZhNFpULWM&export=download&revid=0Bya7uRIlM1kWZXllUDRLWjZ6UjQ5VDdEeWtPZ3ZpKzVWdXVFPQ","sizeInBytes":578695468,"docId":"0Bya7uRIlM1kWZXllUDRLWjZ6UjQ5VDdEeWtPZ3ZpKzVWdXVFPQ","creationDateString":"28/12/12","creator":{"isMe":false,"nickname":"leonardo da vinci","iconUrl":"images/doclist/contact_nopicture.png","editProfileUrl":"editProfile"}}],'obfuscatedUserId': 'ANONYMOUS_17612595759507348808','userDomain': '', 'embedPreviewUri': 'https:\/\/docs.google.com\/file\/d\/0Bya7uRIlM1kWN3g4cUZhNFpULWM\/preview','syncUpdates': [],'contentRenderer': 'video'},{"description":{"raw":"","formatted":""},"download":{"isMissingBlobRef":false,"filename":"Dexter.S07E01.HDTV.XviD-MGD.avi","url":"https://docs.google.com/uc?id=0Bya7uRIlM1kWN3g4cUZhNFpULWM&export=download"},"revision":{"swfUrl":"/static/doclist/client/css/1531528182-uploaderapi.swf","busyIconImageUrl":"https://ssl.gstatic.com/docs/doclist/images/loading_small.gif"},"sharing":{"is_private":false,"visibility_is_restricted_to_domain":false,"visibility_domain_display_name":""},"basicdetails":{"mimeType":"video/x-msvideo","lastModifiedDateString":"28/12/12","creationDateString":"28/12/12","fileSize":"578695468"},"videodetails":{"duration":3282140,"formattedDuration":"54:43","width":640,"height":352,"videoFps":23.976,"videoBitrate":1278920.0,"audioBitrate":128001.0},"thumbnail":{"thumbnail_128":"https://lh4.googleusercontent.com/BqcBvxZ4_8jOGy9d7PY7oncR3m3BC5mzYrKorTQrtoP9BjxG9ED9WyXE28Ap0GanwwMd=s128","thumbnail_full":"https://lh4.googleusercontent.com/BqcBvxZ4_8jOGy9d7PY7oncR3m3BC5mzYrKorTQrtoP9BjxG9ED9WyXE28Ap0GanwwMd=s1600"},"videoplay":{"vid":"857d340b237d4fb0","status":"AVAILABLE","width":640,"height":352,"duration":3282140,"embedType":"PREFER_FLASH","swfUrl":"https://video.google.com/get_player?el=leaf&cc_load_policy=1","embeduri":"https://video.google.com/get_player?docid=0Bya7uRIlM1kWN3g4cUZhNFpULWM&ps=docs&partnerid=30&cc_load_policy=1","iframeEmbedUri":"https://www.youtube.com/iframe_api?html5=1&docid=0Bya7uRIlM1kWN3g4cUZhNFpULWM&ps=docs&partnerid=30&cc_load_policy=1","flashVars":{"status":"ok","hl":"es_419","allow_embed":"0","ps":"docs","partnerid":"30","autoplay":"0","docid":"0Bya7uRIlM1kWN3g4cUZhNFpULWM","abd":"0","public":"false","el":"leaf","title":"Dexter.S07E01.HDTV.XviD-MGD.avi","iurl":"https://docs.google.com/vt?id=0Bya7uRIlM1kWN3g4cUZhNFpULWM","ttsurl":"https://docs.google.com/timedtext?id=0Bya7uRIlM1kWN3g4cUZhNFpULWM&vid=857d340b237d4fb0","reportabuseurl":"https://docs.google.com/abuse?id=0Bya7uRIlM1kWN3g4cUZhNFpULWM","token":"1","plid":"V0QTgcVJR4Lv_g","fmt_stream_map":"18|https://r3---sn-hp576nee.c.docs.google.com/videoplayback?requiressl=yes&shardbypass=yes&cmbypass=yes&id=857d340b237d4fb0&itag=18&source=webdrive&app=docs&ip=181.50.157.34&ipbits=0&expire=1405625079&sparams=requiressl,shardbypass,cmbypass,id,itag,source,ip,ipbits,expire&signature=49F5D7FC85FB145751263FEA498969631F1CE06B.A5BF12D2374ABF3C7943ACB436BA8CA641A103C2&key=ck2&ir=1&ms=nxu&mt=1405621414&mv=m&mws=yes,34|https://r3---sn-hp576nee.c.docs.google.com/videoplayback?requiressl=yes&shardbypass=yes&cmbypass=yes&id=857d340b237d4fb0&itag=34&source=webdrive&app=docs&ip=181.50.157.34&ipbits=0&expire=1405625079&sparams=requiressl,shardbypass,cmbypass,id,itag,source,ip,ipbits,expire&signature=7323C09E547F4F762382306FC2B54BCFCB76E366.9157689903CD8C1E39671160C80CA13D866BBCCF&key=ck2&ir=1&ms=nxu&mt=1405621414&mv=m&mws=yes","fmt_list":"18/640x360/9/0/115,34/640x360/9/0/115","url_encoded_fmt_stream_map":"itag=18&url=https://r3---sn-hp576nee.c.docs.google.com/videoplayback?requiressl=yes&shardbypass=yes&cmbypass=yes&id=857d340b237d4fb0&itag=18&source=webdrive&app=docs&ip=181.50.157.34&ipbits=0&expire=1405625079&sparams=requiressl,shardbypass,cmbypass,id,itag,source,ip,ipbits,expire&signature=49F5D7FC85FB145751263FEA498969631F1CE06B.A5BF12D2374ABF3C7943ACB436BA8CA641A103C2&key=ck2&ir=1&ms=nxu&mt=1405621414&mv=m&mws=yes&type=video/mp4;+codecs="avc1.42001E,+mp4a.40.2"&quality=medium,itag=34&url=https://r3---sn-hp576nee.c.docs.google.com/videoplayback?requiressl=yes&shardbypass=yes&cmbypass=yes&id=857d340b237d4fb0&itag=34&source=webdrive&app=docs&ip=181.50.157.34&ipbits=0&expire=1405625079&sparams=requiressl,shardbypass,cmbypass,id,itag,source,ip,ipbits,expire&signature=7323C09E547F4F762382306FC2B54BCFCB76E366.9157689903CD8C1E39671160C80CA13D866BBCCF&key=ck2&ir=1&ms=nxu&mt=1405621414&mv=m&mws=yes&type=video/x-flv&quality=medium","timestamp":"1405621479190","length_seconds":"3283"}},"webstoreui":{"mimeType":"video/x-msvideo","fileExtension":"avi","moreDriveAppsUrl":"https://chrome.google.com/webstore/category/collection/drive_apps"}});</script>

De ahí necesito sacar:

Código Javascript:
Ver original
  1. https://r3---sn-hp576nee.c.docs.google.com/videoplayback?requiressl=yes&shardbypass=yes&cmbypass=yes&id=857d340b237d4fb0&itag=18&source=webdrive&app=docs&ip=181.50.157.34&ipbits=0&expire=1405625079&sparams=requiressl,shardbypass,cmbypass,id,itag,source,ip,ipbits,expire&signature=49F5D7FC85FB145751263FEA498969631F1CE06B.A5BF12D2374ABF3C7943ACB436BA8CA641A103C2&key=ck2&ir=1&ms=nxu&mt=1405621414&mv=m&mws=yes

PAra después almacenarlo en alguna variable.

Todo esto desde php

Alguna idea?
__________________
@ivancamiloGo
  #2 (permalink)  
Antiguo 17/07/2014, 13:47
 
Fecha de Ingreso: enero-2010
Mensajes: 491
Antigüedad: 14 años, 10 meses
Puntos: 12
Respuesta: Extraer parte especifica de codigo

Es Json busca por aqui: http://php.net/manual/es/book.json.php
  #3 (permalink)  
Antiguo 17/07/2014, 20:56
Avatar de after  
Fecha de Ingreso: junio-2006
Ubicación: De marte
Mensajes: 791
Antigüedad: 18 años, 6 meses
Puntos: 10
Respuesta: Extraer parte especifica de codigo

Gracias. Ya he buscado y arreglado algo así:

Código PHP:
Ver original
  1. $json_string='{"status":"ok","hl":"e..etc";
  2.  
  3. $json=json_decode($json_string,true);
  4.  
  5.  foreach($json as $prop => $value)
  6.  
  7.  
  8. echo  $json['fmt_stream_map'];

y funciona bien.

El problema ahora que tengo es que ese script está dentro de un HTML. Hay forma de decirle al foreach que capte solo el JSON? Ya que cuando le digo que tome la página me salta: Warning: Invalid argument supplied for foreach() lo cual me imagino es poque las primeras líneas son html
__________________
@ivancamiloGo

Etiquetas: especifica, html, parte, variable
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:22.