Reading substrings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Reading substrings

jose marin2
Hi!

I need to 'parse' some html files.

I need to extract the contents of some tags.
For example, I need to read the text between "<head>"
and "</head>".

It's possible?

Thanks!




               
_______________________________________________________
Abra sua conta no Yahoo! Mail: 1GB de espaço, alertas de e-mail no celular e anti-spam realmente eficaz.
http://mail.yahoo.com.br/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reading substrings

Andrew Wilson-4
Look at Lua Expat. http://www.keplerproject.org/luaexpat/      AGRW

On 5/30/06, Jose Marin <[hidden email]> wrote:
Hi!

I need to 'parse' some html files.

I need to extract the contents of some tags.
For example, I need to read the text between "<head>"
and "</head>".

It's possible?

Thanks!





_______________________________________________________
Abra sua conta no Yahoo! Mail: 1GB de espaço, alertas de e-mail no celular e anti-spam realmente eficaz.
http://mail.yahoo.com.br/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reading substrings

Petite Abeille
In reply to this post by jose marin2

On May 30, 2006, at 21:55, Jose Marin wrote:

> I need to 'parse' some html files.

Take a look at Roberto Ierusalimschy's "Classic Lua-only" XML parser
for a straightforward example:

http://lua-users.org/wiki/LuaXml

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reading substrings

jose marin2
If it's useful to someon, I've solved today, using
string.find!

Thanks for your tips, guys!




               
_______________________________________________________
Navegue com o Yahoo! Acesso Grátis, assista aos jogos do Brasil na Copa e ganhe prêmios de hora em hora!
http://br.yahoo.com/artilheirodacopa/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reading substrings

Andrew Wilson-4
Sure, it would be useful, send the code snippet.  AGRW

On 5/31/06, Jose Marin <[hidden email] > wrote:
If it's useful to someon, I've solved today, using
string.find!

Thanks for your tips, guys!





_______________________________________________________
Navegue com o Yahoo! Acesso Grátis, assista aos jogos do Brasil na Copa e ganhe prêmios de hora em hora!
http://br.yahoo.com/artilheirodacopa/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reading substrings

jose marin2

Warning: need error checking, and change the BASIC
style variables!


function extractContents(s, pattern1, pattern2)
local a, b, d, c

        a, b = string.find (s, pattern1 )
        c, d = string.find (s, pattern2 )

        return string.sub(s, b+1, c-1)
end


To print the title of a html page (loaded on the
'page' variable):

print( extractContents(page, "<TITLE>", "</TITLE>"))

Hope this could be useful to someone...


--- Andrew Wilson <[hidden email]> escreveu:

> Sure, it would be useful, send the code snippet.
> AGRW
>
> On 5/31/06, Jose Marin <[hidden email]>
> wrote:
> >
> > If it's useful to someon, I've solved today, using
> > string.find!
> >
> > Thanks for your tips, guys!
> >
> >
> >
> >
> >
> >
>

__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger
http://br.beta.messenger.yahoo.com/ 
Loading...