• Publicidad

LWP

¿Apenas comienzas con Perl? En este foro podrás encontrar y hacer preguntas básicas de Perl con respuestas aptas a tu nivel.

LWP

Notapor laliebre » 2005-08-16 20:31 @897

Saludos.

Por favor, quisiera una explicación clara para qué sirve la librería LWP, en qué momentos usarla, etc., etc., etc.

Gracias,


Cris
laliebre
Perlero nuevo
Perlero nuevo
 
Mensajes: 10
Registrado: 2004-05-03 16:01 @709

Publicidad

Notapor kidd » 2005-08-16 20:42 @904

Hola.

Te recomiendo leer el manual del módulo LWP. Ahí al principio viene la descripción general del módulo:

DESCRIPTION

The libwww-perl collection is a set of Perl modules which provides a simple and consistent application programming interface (API) to the World-Wide Web. The main focus of the library is to provide classes and functions that allow you to write WWW clients. The library also contain modules that are of more general use and even classes that help you implement simple HTTP servers.

Most modules in this library provide an object oriented API. The user agent, requests sent and responses received from the WWW server are all represented by objects. This makes a simple and powerful interface to these services. The interface is easy to extend and customize for your own needs.

The main features of the library are:
  • Contains various reusable components (modules) that can be used separately or together.
  • Provides an object oriented model of HTTP-style communication. Within this framework we currently support access to http, https, gopher, ftp, news, file, and mailto resources.
  • Provides a full object oriented interface or a very simple procedural interface.
  • Supports the basic and digest authorization schemes.
  • Supports transparent redirect handling.
  • Supports access through proxy servers.
  • Provides parser for robots.txt files and a framework for constructing robots.
  • Supports parsing of HTML forms.
  • Implements HTTP content negotiation algorithm that can be used both in protocol modules and in server scripts (like CGI scripts).
  • Supports HTTP cookies.
  • Some simple command line clients, for instance lwp-request and lwp-download.

Ahora, si lo que quieres es hacer funciones básicas como por ejemplo leer el contenido de un URL, puedes usar el módulo LWP::Simple. Así por ejemplo, para leer el contenido de un URL todo lo que tienes que hacer es:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. use strict;
  2. use LWP::Simple;
  3.  
  4. print get("http://google.com/");
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4



SALUDOS
Última edición por kidd el 2005-08-16 20:46 @907, editado 1 vez en total
Uriel Lizama Perl programmer fundador de Perl en Español
Perl Programming Language
Avatar de Usuario
kidd
Creador de Perl en Español
Creador de Perl en Español
 
Mensajes: 1166
Registrado: 2003-10-15 16:52 @744
Ubicación: México

Re: LWP

Notapor Perl user » 2005-08-16 20:44 @906

La biblioteca LWP significa "Library for WWW in Perl", es decir, es un conjunto de herramientas las cuales le permiten a Perl comportarse como si fuera un navegador Web, así es, un navegador ( browser ), el cual puede abrir páginas, enviar datos a formularios, usar HTTPS ( secure http ), extraer información de páginas, cookies, y cualquier cosa que haces normalmente con un navegador.

Otro módulo importante es WWW::Mechanize. Este módulo vaya que es un navegador andante en un solo objeto, a diestra y siniestra, es una subclase de LWP, y tiene demasiadas características, útil para web testing, por ejemplo.

Para ejemplos de uso, documentación, etcétera, puedes consultar la página de manual de LWP, LWP Tutorial y WWW::Mechanize.

Para una guía muy buena sobre LWP y Perl, voy a permitirme hacerle comercial a mi buen amigo Sean M. Burke, con su libro "Perl & LWP" de Editorial O'Reilly. Y claro otros recursos sobre LWP podrías encontrarlos en la página de columnas publicadas de Randal L. Schwartz.

Saludos,
Marco A. Manzo
[email protected]
http://www.unixmonkeys.com/amnesiac/
Perl Programming Language
Perl user
Maestro honorario
Maestro honorario
 
Mensajes: 271
Registrado: 2004-11-03 21:11 @924


Volver a Básico

¿Quién está conectado?

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

cron