[LugBS] estrarre stringhe da files html
Enrico Colombini
erix a erix.it
Ven 18 Feb 2011 21:29:52 UTC
Lo script Lua che riporto sotto ti estrae i campi su linee separate (ne
ho messi tre, gli altri ce li metti tu per imitazione).
Ti serve l'eseguibile Lua se non l'hai gia' sul sistema
(http://luabinaries.sourceforge.net/download.html).
cat iltuofile | lua getdata.lua
(type invece di cat se sei sotto Windows)
---------------------
getdata.lua
---------------------
local match = string.match
local name
local address
local cap
local line = ''
while line do
line = io.read('*l')
name = name or match(line, '>([^<]+)<%/h1>')
address = address or match(line, 'INDIRIZZO%: <%/span>([^<]+)<%/div>')
cap = cap or match(line, 'CAP%: <%/span>([^<]+)<%/div>')
-- etc.
end
io.write(name, '\n')
io.write(address, '\n')
io.write(cap, '\n')
---------------------
(quick & quite dirty)
--
.Erix.
Maggiori informazioni sulla lista
Lug
|