• Publicidad

Obtener información de un archivo html

¿Ya sabes lo que es una referencia? Has progresado, el nível básico es cosa del pasado y ahora estás listo para el siguiente nivel.

Obtener información de un archivo html

Notapor willbender » 2013-10-25 11:14 @509

¡Hola a todos! ¿Alguien me podría ayudar? Tengo esta tarea.
Tengo un archivo en formato HTML de este tipo:
Sintáxis: [ Descargar ] [ Ocultar ]
Using html4strict Syntax Highlighting
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><HTML>
  2. <HEAD>
  3. <TITLE></TITLE>
  4. </HEAD>
  5. <BODY>
  6. <A name=1></a>I n f o r m a t i o n   a s   o f   2 4   S e p t e m b e r   2 0 1 3   h a s   b e e n   u s e d   i n   p r e p a r a t i o n   o f   t h i s   d i r e c t o r y .  <br>
  7. <hr>
  8. <A name=2></a>PREFACE<br>
  9. The Central Intelligence Agency publishes and updates the online directory of<i> Chiefs of State and Cabinet Members of<br>Foreign Governments  </i>weekly. The directory is intended to be used primarily as a reference aid and includes as many<br>governments of the world as is considered practical, some of them not officially recognized by the United States.<br>Regimes with which the United States has no diplomatic exchanges are indicated by the initials NDE.<br>
  10. G o v e r n m e n t s   a r e   l i s t e d   i n   a l p h a b e t i c a l   o r d e r   a c c o r d i n g   t o   t h e   m o s t   c o m m o n l y   u s e d   v e r s i o n   o f   e a c h   c o u n t r y ' s   n a m e .<br>The spelling of the personal names in this directory follows transliteration systems generally agreed upon by US<br>Government agencies, except in the cases in which officials have stated a preference for alternate spellings of their<br>n a m e s .<br>
  11.  <br>
  12. <b>NOTE: Although the head of the central bank is listed for each country, in most cases he or she is not a Cabinet<br>member. Ambassadors to the United States and Permanent Representatives to the UN, New York, have also been<br>included.</b><br>
  13. <b>P a g e   2   o f   2 1 2</b><br>
  14. <hr>
  15. <A name=3></a>Key to Abbreviations<br>
  16. A d m .<br>
  17. A d m i r a l<br>
  18. A d m i n .<br>
  19. A d m i n i s t r a t i v e ,   A d m i n i s t r a t i o n<br>
  20. A s s t .<br>
  21. A s s i s t a n t<br>
  22. Brig.<br>
  23. Brigadier<br>
  24. C a p t .<br>
  25. C a p t a i n<br>
  26. C d r .<br>
  27. C o m m a n d e r<br>
  28. C d t e .<br>
  29. C o m a n d a n t e<br>
  30. C h m n .<br>
  31. C h a i r m a n ,   C h a i r w o m a n<br>
  32. Col.<br>
  33. Colonel<br>
  34. Ctte.<br>
  35. C o m m i t t e e<br>
  36. Del.<br>
  37. Delegate<br>
  38. D e p .<br>
  39. D e p u t y<br>
  40. D e p t .<br>
  41. D e p a r t m e n t<br>
  42. Dir.<br>
  43. D i r e c t o r<br>
  44. Div.<br>
  45. Division<br>
  46. Dr.<br>
  47. D o c t o r<br>
  48. Eng.<br>
  49. Engineer<br>
  50. Fd. Mar.<br>
  51. Field Marshal<br>
  52. Fed.<br>
  53. F e d e r a l<br>
  54. Gen.<br>
  55. G e n e r a l<br>
  56. Govt.<br>
  57. G o v e r n m e n t<br>
  58. Intl.<br>
  59. I n t e r n a t i o n a l<br>
  60. Lt.<br>
  61. L i e u t e n a n t<br>
  62. Maj.<br>
  63. Major<br>
  64. Mar.<br>
  65. M a r s h a l<br>
  66. Mbr.<br>
  67. M e m b e r<br>
  68. Min.<br>
  69. Minister, Ministry<br>
  70. NDE<br>
  71. No Diplomatic Exchange<br>
  72. Org.<br>
  73. O r g a n i z a t i o n<br>
  74. Pres.<br>
  75. P r e s i d e n t<br>
  76. Prof.<br>
  77. P r o f e s s o r<br>
  78. RAdm.<br>
  79. Rear Admiral<br>
  80. Ret.<br>
  81. R e t i r e d<br>
  82. Sec.<br>
  83. Secretary<br>
  84. VAdm.<br>
  85. Vice Admiral<br>
  86. VMar.<br>
  87. Vice Marshal<br>
  88. <b>P a g e   3   o f   2 1 2</b><br>
  89. <hr>
  90. <A name=4></a><b> </b><br>
  91. <b>Afghanistan </b><br>
  92. Last Updated: 6 Sep 2013 <br>
  93. Pres.  <br>
  94. Hamid KARZAI<br>
  95. First Vice Pres. <br>
  96. Mohammad FAHIM Khan<br>
  97. Second Vice Pres.  <br>
  98. Abdul Karim KHALILI<br>
  99. Min. of Agriculture, Irrigation, &amp; Livestock  <br>
  100. Mohammad Asif RAHIMI<br>
  101. Min. of Border &amp; Tribal Affairs  <br>
  102.  <br>
  103. Min. of Commerce &amp; Industry  <br>
  104. Anwar Ul-Haq AHADY<br>
  105. Min. of Communications <br>
  106. Amirzai SANGIN<br>
  107. Min. of Counternarcotics <br>
  108. Zarar Ahmad Moqbel OSMANI<br>
  109. Min. of Defense <br>
  110. BISMULLAH Muhammadi Khan<br>
  111. Min. of Economy  <br>
  112. Abdul Hadi ARGHANDIWAL<br>
  113. Min. of Education  <br>
  114. Faruq WARDAK<br>
  115. Min. of Energy &amp; Water  <br>
  116. Ismail KHAN<br>
  117. Min. of Finance <br>
  118. Omar ZAKHILWAL<br>
  119. Min. of Foreign Affairs  <br>
  120. Zalmay RASSOUL<i>, Dr.</i><br>
  121. Min. of Hajj &amp; Islamic Affairs  <br>
  122. Mohammad Yusuf NIAZI<br>
  123. Min. of Health  <br>
  124. Suraya DALIL<i>, Dr.</i><br>
  125. Min. of Higher Education  <br>
  126. Obaidullah OBAID<br>
  127. Min. of Information &amp; Culture  <br>
  128. Sayed Makhdum RAHIN<br>
  129. Min. of Interior (Acting)  <br>
  130. Mohammad Umer DAUDZAI<br>
  131. Min. of Justice  <br>
  132. Habibullah GHALEB<br>
  133. Min. of Martyred, Disabled, Labor, &amp; Social Affairs  <br>
  134. Amena AFZALI<br>
  135. Min. of Mines &amp; Petroleum  <br>
  136. Wahidullah SHAHRANI<br>
  137. Min. of Public Works  <br>
  138. Najibullah AOUDJAN<br>
  139. Min. of Refugees &amp; Repatriation <br>
  140. Jamahir ANWARI<br>
  141. Min. of Rural Rehabilitation &amp; Development  <br>
  142. Wais BARMACK<br>
  143. Min. of Transportation &amp; Civil Aviation  <br>
  144. Daoud Ali NAJAFI<i>, Dr.</i><br>
  145. Min. of Urban Development <br>
  146. Hassan ABDULHAI<br>
  147. Min. of Women's Affairs <br>
  148. Hasan Bano GHAZANFAR<br>
  149. National Security Adviser  <br>
  150. Rangin Dadfar SPANTA<br>
  151. Dir. Gen. (Acting), National Directorate of Security <br>
  152. Rahmatullah NABIL<br>
  153. Governor, Da Afghanistan Bank  <br>
  154. Noorullah DELAWARI<br>
  155. A m b a s s a d o r   t o   t h e   U S <br>
  156. Eklil Ahmad HAKIMI<br>
  157. Permanent Representative to the UN, New York <br>
  158. Zahir TANIN<br>
  159. <b>P a g e   4   o f   2 1 2</b><br>
  160. <hr>
  161. <A name=5></a><b> </b><br>
  162. <b>Albania </b><br>
  163. Last Updated: 17 Sep 2013 <br>
  164. Pres.  <br>
  165. Bujar NISHANI<br>
  166. Prime Min. <br>
  167. Edi RAMA<br>
  168. Dep. Prime Min.  <br>
  169. Niko PELESHI<br>
  170. Min. of Agriculture, Food, &amp; Consumer Protection  <br>
  171. Edmond PANARITI<br>
  172. Min. of Culture  <br>
  173. Mirela KUMBARO<br>
  174. Min. of Defense <br>
  175. Mrike &quot;Mimi&quot; KODHELI<br>
  176. Min. of Economic Development, Trade, &amp; Entrepreneurship  <br>
  177. Arben AHMETAJ<br>
  178. Min. of Education &amp; Sports <br>
  179. Lindita NIKOLLI<br>
  180. Min. of Energy &amp; Industry <br>
  181. Damian GJIKNURI<br>
  182. Min. of Environment  <br>
  183. Lefter KOKA<br>
  184. Min. of Finance <br>
  185. Shkelqim CANI<br>
  186. Min. of Foreign Affairs  <br>
  187. Ditmir BUSHATI<br>
  188. Min. of Health  <br>
  189. Ilir BEQJA<br>
  190. Min. of Innovation &amp; Public Admin.  <br>
  191. Milena HARITO<br>
  192. Min. of Integration <br>
  193. Klajda GJOSHA<br>
  194. Min. of Interior  <br>
  195. Sajmir TAHIRI<br>
  196. Min. of Justice  <br>
  197. Nasip NACO<br>
  198. Min. of Local Govt. Affairs <br>
  199. Bled CUCI<br>
  200. Min. of Relations With Parliament <br>
  201. Ilirjan CELIBASHI<br>
  202. Min. of Social Welfare &amp; Youth <br>
  203. Erion VELIAJ<br>
  204. Min. of Transport &amp; Infrastructure  <br>
  205. Edmond HAXHINASTO<br>
  206. Min. of Urban Development &amp; Tourism  <br>
  207. Englantina GJERMENI<br>
  208. Governor, Bank of Albania  <br>
  209. Ardian FULLANI<br>
  210. A m b a s s a d o r   t o   t h e   U S <br>
  211. Gilbert GALANXHI<br>
  212. Permanent Representative to the UN, New York <br>
  213. Ferit HOXHA<br>
  214. <b>P a g e   5   o f   2 1 2</b><br>
  215. <hr>
  216. <A name=6></a><b> </b><br>
  217. <b>Algeria </b><br>
  218. Last Updated: 20 Sep 2013 <br>
  219. Pres.  <br>
  220.  
Coloreado en 0.008 segundos, usando GeSHi 1.0.8.4

De este archivo necesito capturar hacia una base de datos los campos siguientes:

El pais que está en esta etiqueta:
Sintáxis: [ Descargar ] [ Ocultar ]
Using html4strict Syntax Highlighting
  1. <A name=6></a><b> </b><br>
  2. <b>Algeria </b><br>
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4


Luego viene un párrafo en donde se describen nombres de personas y lo que son, es decir, presidente, vicepresidente, ministro de esto, ministro de aquello, etc. Esos datos son los que necesito capturar, es decir, capturo todos los nombres de las personas con su descripción política y lo apunto hacia una base de datos.

La conexion ya la tengo hecha. Ya tengo tres variables dentro de un "foreach" esperando para insertar a la base. Realmente ese no es el problema.

El problema real es cómo recorrer todo el archivo y definir que cuando encuentre un nombre de país tome como datos para ese país el parrafo que abarca desde el nombre del país hasta el dato del siguiente país.

¿Me pueden ayudar? Agradecería mucho su ayuda. Éxitos.
willbender
Perlero nuevo
Perlero nuevo
 
Mensajes: 24
Registrado: 2012-07-16 17:22 @765
Ubicación: Guatemala

Publicidad

Re: Obtener información de un archivo html

Notapor tolyn » 2013-10-25 12:14 @551

WILL....

Puede hacer algo así.

He creado una variable $ContentPage, la cual contiene el código HTML.
Le he dicho que me saque lo que está entre Afghanistan y Algeria y lo deje en $1.
Luego lo paso a una matriz cada línea y de ahí la recorro diciendo que la primera línea es el cargo y la segunda el nombre... Lo he probado y funciona. Eso sí, hay que limpiarlo para sacarle los <br> y la basura que no ocupes.
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. my $a = $ContentPage =~ /\<b>Afghanistan <\/b><br>(.*?)<b>Algeria/si;
  2. if ( $a == 1 ) {
  3.     $ContentPage = $1;
  4.     my @Lineas = split( /\n/, $ContentPage );
  5.     my $contador = 1;
  6.     foreach $linea (@Lineas) {
  7.         my $b = $linea =~ /\Last(.*?)> /si;
  8.  
  9.         if ( !$b ) {
  10.             if ( $contador == 1 ) {
  11.                 print "\n\nNOMBRE:" . $linea;
  12.             }
  13.             if ( $contador == 2 ) {
  14.                 print "CARGO:" . $linea . "";
  15.             }
  16.             $contador++;
  17.         }
  18.         if ( $contador == 3 ) {
  19.             $contador = 1;
  20.         }
  21.     }
  22. }
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4

RESULTADO:
Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
NOMBRE:Pres.  <br>CARGO:Hamid KARZAI<br>
NOMBRE:First Vice Pres. <br>CARGO:Mohammad FAHIM Khan<br>
NOMBRE:Second Vice Pres.  <br>CARGO:Abdul Karim KHALILI<br>
NOMBRE:Min. of Agriculture, Irrigation, &amp; Livestock  <br>CARGO:Mohammad Asif RAHIMI<br>
NOMBRE:Min. of Border &amp; Tribal Affairs  <br>CARGO: <br>
NOMBRE:Min. of Commerce &amp; Industry  <br>CARGO:Anwar Ul-Haq AHADY<br>
NOMBRE:Min. of Communications <br>CARGO:Amirzai SANGIN<br>
NOMBRE:Min. of Counternarcotics <br>CARGO:Zarar Ahmad Moqbel OSMANI<br>
NOMBRE:Min. of Defense <br>CARGO:BISMULLAH Muhammadi Khan<br>
NOMBRE:Min. of Economy  <br>CARGO:Abdul Hadi ARGHANDIWAL<br>
NOMBRE:Min. of Education  <br>CARGO:Faruq WARDAK<br>
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4


No soy experto pero eso se me ocurrió... igual puedes mejorarlo... Ahora, si necesitas que el programa vaya a la página web y saque esta información tienes que sacar el código con el WWW::Mechanize y la dejas en la variable $ContentPage.

Saludos...
tolyn
Perlero nuevo
Perlero nuevo
 
Mensajes: 14
Registrado: 2011-10-19 08:20 @389

Re: Obtener información de un archivo html

Notapor willbender » 2013-10-25 12:17 @553

tolyn, muchas gracias. Probaré el código que me indicas. ¡Muy amable!
willbender
Perlero nuevo
Perlero nuevo
 
Mensajes: 24
Registrado: 2012-07-16 17:22 @765
Ubicación: Guatemala

Re: Obtener información de un archivo html

Notapor willbender » 2013-10-28 10:45 @489

No me ha funcionado la solución que me indicabas. Una duda: yo estoy haciendo esto con el código que me envías:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. open( PEP, $file ) || die "ERROR: No puedo abrir el fichero $_\n";
  2.  
  3. my $a = <PEP> =~ /\<b>Afghanistan <\/b><br>(.*?)<b>Algeria/si;
  4. print;
  5. if ( $a == 1 ) {
  6.     $file = $1;
  7.     my @Lineas = split( /\n/, PEP );
  8.     my $contador = 1;
  9.     foreach $linea (@Lineas) {
  10.         my $b = $linea =~ /\Last(.*?)> /si;
  11.  
  12.         if ( !$b ) {
  13.             if ( $contador == 1 ) {
  14.                 print "\n\nNOMBRE:" . $linea;
  15.             }
  16.             if ( $contador == 2 ) {
  17.                 print "CARGO:" . $linea . "";
  18.             }
  19.             $contador++;
  20.         }
  21.         if ( $contador == 3 ) {
  22.             $contador = 1;
  23.         }
  24.     }
  25. }
  26. close($file);
  27.  
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

¡No me funciona! Lo corro desde consola y lo apunto a un archivo txt.txt y simplemente me imprime el nombre de mi archivo. ¿Me puedes ayudar? Gracias.
willbender
Perlero nuevo
Perlero nuevo
 
Mensajes: 24
Registrado: 2012-07-16 17:22 @765
Ubicación: Guatemala

Re: Obtener información de un archivo html

Notapor tolyn » 2013-10-28 11:10 @507

will, ¿has impreso "PEL" para ver si tiene el HTML...? Lo que yo hice fue crear una variable

$ContentPage="AKI PEGE TODO EL CODIGO HTML QUE PUBLICASTE... ";

Prueba imprimiendo tu variable... O carga el HTML a la variable como lo hice yo...

Disculpa la demora pero estuve desconectado...

Saludos...
tolyn
Perlero nuevo
Perlero nuevo
 
Mensajes: 14
Registrado: 2011-10-19 08:20 @389

Re: Obtener información de un archivo html

Notapor explorer » 2013-10-28 20:41 @904

Como estamos en el foro Intermedio, aquí publico mi solución basada en expresiones regulares:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!/usr/bin/env perl
  2. use v5.14;
  3. use autodie;
  4. use utf8::all;
  5. use File::Slurp;
  6.  
  7. ## Leemos el archivo
  8. my $html = read_file('code_35850.html');
  9.  
  10. ## Definición de lo que buscamos
  11. my $regex_país   = qr{  ^
  12.                         <A[ ]name=\d+></a>            .+? \n
  13.                         <b> \s* (?<país>.+?) \s* </b> .+? \n
  14.                         Last[ ]Updated:[ ]            .+? \n
  15.                    }mix;
  16. my $regex_eol    = qr{\s*? <br> \s*? \n}ix;
  17. my $regex_cargo  = qr{^ (?<!<) (?<cargo>.+?)  $regex_eol }mix;
  18. my $regex_nombre = qr{^ (?<!<) (?<nombre>.+?) $regex_eol }mix;
  19. my $regex_staff  = qr{(?<staff>(?:$regex_cargo $regex_nombre)+)}x;
  20.  
  21. ## Buscamos
  22. while ($html =~ /$regex_país $regex_staff/mxg) {
  23.  
  24.     my($país, $staff) = ($+{país}, $+{staff});
  25.  
  26.     say "País: [$país]";
  27.  
  28.     while ($staff =~ /$regex_cargo $regex_nombre/gx) {
  29.         say "\t[$+{cargo}]", "\t[$+{nombre}]";
  30.     }
  31. }
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4
Salida:
Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
[Afghanistan]
        [Pres.] [Hamid KARZAI]
        [First Vice Pres.]      [Mohammad FAHIM Khan]
        [Second Vice Pres.]     [Abdul Karim KHALILI]
        [Min. of Agriculture, Irrigation, &amp; Livestock]      [Mohammad Asif RAHIMI]
        [Min. of Border &amp; Tribal Affairs]   [ ]
        [Min. of Commerce &amp; Industry]       [Anwar Ul-Haq AHADY]
        [Min. of Communications]        [Amirzai SANGIN]
        [Min. of Counternarcotics]      [Zarar Ahmad Moqbel OSMANI]
        [Min. of Defense]       [BISMULLAH Muhammadi Khan]
        [Min. of Economy]       [Abdul Hadi ARGHANDIWAL]
        [Min. of Education]     [Faruq WARDAK]
        [Min. of Energy &amp; Water]    [Ismail KHAN]
        [Min. of Finance]       [Omar ZAKHILWAL]
        [Min. of Foreign Affairs]       [Zalmay RASSOUL<i>, Dr.</i>]
        [Min. of Hajj &amp; Islamic Affairs]    [Mohammad Yusuf NIAZI]
        [Min. of Health]        [Suraya DALIL<i>, Dr.</i>]
        [Min. of Higher Education]      [Obaidullah OBAID]
        [Min. of Information &amp; Culture]     [Sayed Makhdum RAHIN]
        [Min. of Interior (Acting)]     [Mohammad Umer DAUDZAI]
        [Min. of Justice]       [Habibullah GHALEB]
        [Min. of Martyred, Disabled, Labor, &amp; Social Affairs]       [Amena AFZALI]
        [Min. of Mines &amp; Petroleum] [Wahidullah SHAHRANI]
        [Min. of Public Works]  [Najibullah AOUDJAN]
        [Min. of Refugees &amp; Repatriation]   [Jamahir ANWARI]
        [Min. of Rural Rehabilitation &amp; Development]        [Wais BARMACK]
        [Min. of Transportation &amp; Civil Aviation]   [Daoud Ali NAJAFI<i>, Dr.</i>]
        [Min. of Urban Development]     [Hassan ABDULHAI]
        [Min. of Women's Affairs]       [Hasan Bano GHAZANFAR]
        [National Security Adviser]     [Rangin Dadfar SPANTA]
        [Dir. Gen. (Acting), National Directorate of Security]  [Rahmatullah NABIL]
        [Governor, Da Afghanistan Bank] [Noorullah DELAWARI]
        [A m b a s s a d o r   t o   t h e   U S]       [Eklil Ahmad HAKIMI]
        [Permanent Representative to the UN, New York]  [Zahir TANIN]
[Albania]
        [Pres.] [Bujar NISHANI]
        [Prime Min.]    [Edi RAMA]
        [Dep. Prime Min.]       [Niko PELESHI]
        [Min. of Agriculture, Food, &amp; Consumer Protection]  [Edmond PANARITI]
        [Min. of Culture]       [Mirela KUMBARO]
        [Min. of Defense]       [Mrike &quot;Mimi&quot; KODHELI]
        [Min. of Economic Development, Trade, &amp; Entrepreneurship]   [Arben AHMETAJ]
        [Min. of Education &amp; Sports]        [Lindita NIKOLLI]
        [Min. of Energy &amp; Industry] [Damian GJIKNURI]
        [Min. of Environment]   [Lefter KOKA]
        [Min. of Finance]       [Shkelqim CANI]
        [Min. of Foreign Affairs]       [Ditmir BUSHATI]
        [Min. of Health]        [Ilir BEQJA]
        [Min. of Innovation &amp; Public Admin.]        [Milena HARITO]
        [Min. of Integration]   [Klajda GJOSHA]
        [Min. of Interior]      [Sajmir TAHIRI]
        [Min. of Justice]       [Nasip NACO]
        [Min. of Local Govt. Affairs]   [Bled CUCI]
        [Min. of Relations With Parliament]     [Ilirjan CELIBASHI]
        [Min. of Social Welfare &amp; Youth]    [Erion VELIAJ]
        [Min. of Transport &amp; Infrastructure]        [Edmond HAXHINASTO]
        [Min. of Urban Development &amp; Tourism]       [Englantina GJERMENI]
        [Governor, Bank of Albania]     [Ardian FULLANI]
        [A m b a s s a d o r   t o   t h e   U S]       [Gilbert GALANXHI]
        [Permanent Representative to the UN, New York]  [Ferit HOXHA]
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: Obtener información de un archivo html

Notapor willbender » 2013-10-29 16:32 @731

Gracias a ambos por sus respuestas.

Tolyn: sí imprime el HTML. Solucioné el problema cambiando la raíz del html.

explorer: comprobaré tu solución.

Gracias.
willbender
Perlero nuevo
Perlero nuevo
 
Mensajes: 24
Registrado: 2012-07-16 17:22 @765
Ubicación: Guatemala

Re: Obtener información de un archivo html

Notapor willbender » 2013-10-29 17:21 @765

explorer, buenas tardes.

¿Me podrías explicar un poco la sintaxis de la la expresión regular entre qr y mix, si fuera tan amable? Me pierdo un poco.

Gracias, ¡muy amable!
willbender
Perlero nuevo
Perlero nuevo
 
Mensajes: 24
Registrado: 2012-07-16 17:22 @765
Ubicación: Guatemala

Re: Obtener información de un archivo html

Notapor explorer » 2013-10-29 18:43 @821

En el código hay siete patrones y dos expresiones regulares. El operador qr() define patrones, que más tarde se usarán dentro de una expresión regular.

¿Cuál de ellas no ves claro?

Tienes información general sobre las expresiones regulares y los patrones en tu propio ordenador en perldoc perlre, y en la Web (traducido al español).
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: Obtener información de un archivo html

Notapor willbender » 2013-10-31 11:22 @515

Creo que mi problema tiene que ver con la versión de Perl. Esto es lo que me despliega

"This is perl, v5.8.8 built for x86_64-linux-thread-multi"

El problema es que no puedo actualizar la versión de Perl del servidor en donde correrá este perl debido a que ya hay perl colocados y que funcionan ahí y, pues, definitivamente no deseo entrar en conflictos con los demás programas.

El problema que me da al querer instalar el utf8::all con el cpan es:
Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
force install utf8::all
Running install for module 'utf8::all'
Running Build for D/DO/DOHERTY/utf8-all-0.011.tar.gz
  Has already been unwrapped into directory /root/.cpan/build/utf8-all-0.011-9_Moz_

  CPAN.pm: Building D/DO/DOHERTY/utf8-all-0.011.tar.gz

DOHERTY/utf8-all-0.011.tar.gz requires perl '5.010'; you have only 5.008008; giving up
  DOHERTY/utf8-all-0.011.tar.gz
  [prereq] -- NOT OK

Running Build test
  Can't test without successful make
Running Build install
  Make had returned bad status, install seems impossible
Failed during this command:
 DOHERTY/utf8-all-0.011.tar.gz                : make NO requires perl '5.010'
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4

Por consiguiente no sé si se puede modificar un poco la expresión regular para que la versión de Perl pueda manejarlo. ¿Me puedes ayudar?

Gracias de todas maneras.
willbender
Perlero nuevo
Perlero nuevo
 
Mensajes: 24
Registrado: 2012-07-16 17:22 @765
Ubicación: Guatemala

Siguiente

Volver a Intermedio

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 1 invitado