pagina=$1
if [ ${pagina:0:4} = "http" ]; then
#web
curl $pagina | grep -o 'href=['"'"'"][^"'"'"']*['"'"'"]' | sed -e 's/^href=["'"'"']//' -e 's/["'"'"']$//' >> links.txt
else
#locale
less $pagina | grep -o 'href=['"'"'"][^"'"'"']*['"'"'"]' | sed -e 's/^href=["'"'"']//' -e 's/["'"'"']$//' >> links.txt
fi
Ho provato a farlo in livecode e il risultato è questo:
put $1 into indirizzo#web o locale?if (char 1 to 4 of $1) is not "http" then put "file:" before indirizzoput url indirizzo into paginaset itemdel to "="put the number of items of pagina into nnrepeat with i=1 to nn if (char -4 to -1 of item i of pagina ) = "href" then put word 1 of item (i+1) of pagina & return after listaLinkend repeatput listaLink
Sono 9 righe, solo due di più di bash, ma forse molto più chiare. Voi che ne dite?
Nessun commento:
Posta un commento