Suppose I wanna DL a web page and apply pattern matching to it... The DLing part is what i am interested in... If anyone helped me id be grateful
Look in this thread (http://board.univ-angers.fr/thread.php?threadid=2565&boardid=11) similar problem ....
I am happy to see you back here ;)
I hope you had a good summertime ..
Thank you, mate, but i wanted someone to EXPLAIN me this stuff, cause if i do not understand what it is, i cannot (and are not willing to) write a script using it. I hope you understand me.
Like how do you mean ..a sciprt that streams a code from a html page into a file ?
OK
So, i need a bit info on how lua can made 2 connect 2 internet and download a page. After the page is downloaded, i need no help, i can do pattern matching alone hehe :P
Sorry but i havent found this part in lua4 book... am i st00pid or it really is not there? ?(
Let's get this script, i wanna know what are these socket, err and other stuff. If u explain me what is the process then i can go on.
-- IMDBBOT By [NL]Pur and GoldMember
-- last updated: 8 juni 2003
MainBotName = "[bot]Security" -- Rename to match your Main hub bot
BotName = "[bot]iMDb"
TimeSpanInMinutes = 30
-- Commands --
cmd1 = "?search" --
cmd2 = "?topmovies" -- no arguments
cmd4 = "?restrict" -- arguments
cmd5 = "?settings" -- no arguments
cmd6 = "?sort" -- arguments - best search matches first
-- - alphabetically
-- - chronologically
cmd7 = "?type" -- arguments - Regular expression
-- - fuzzy search
-- - word(s)
cmd8 = "?fromyear" -- argument search from which year
cmd9 = "?toyear" -- argument search to which year
cmda = "?help"
-- Default Settings --
RegisterBot = "PM" -- PM = Results in PM , MainChat = Results in Main Chat
usetimer = "0" -- 1 = Updates of Top15 with use of the timer , 0 = Updates when command ?topmovies is used
searchfor = '&tv=only'
sorts = '&sort=smart'
type = '&type=substring'
fromyear = '&from_year1890'
toyear = '&to_year2010'
function Main()
if (RegisterBot=="PM") then
frmHub:RegBot(BotName)
else
frmHub:UnregBot(BotName)
end
SendPmToOps(MainBotName,date("iMDb Activated [%d %B %Y l %X] ("..RegisterBot.." Mode)"))
SetTimer(TimeSpanInMinutes*60000)
StartTimer()
end
function OnTimer()
if (usetimer=="1") then
getNews1()
end
end
function Get1Arg(data)
s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(.+)" )
return arg
end
function wr(target,text)
target:SendPM(BotName,text)
end
function DataArrival(curUser,data)
if (strsub(data, 1, 1) == "<") then
data = strsub(data,1,strlen(data)-1)
if (strfind(strlower(data), strlower(cmd1))) then
arg = Get1Arg(data)
if (arg==nil) then
else
sp = strchar(32)
arg = gsub(arg, sp, '+')
findNews(curUser,arg..sorts..type..searchfor..fromyear..toyear)
end
end
if (strfind(strlower(data), strlower(cmd2))) then
if (usetimer=="0") then
getNews1()
end
headpm(curUser)
readfile(curUser,"top15.txt")
end
if (strfind(strlower(data), strlower(cmda))) then
readfile(curUser,"helpimdb.txt")
end
if (getcmd(data,cmd4)==1) and (curUser.bOperator) then
if (arg=='movie') then searchfor='&tv=off' end
if (arg=='both') then searchfor='&tv=both' end
if (arg=='tv') then searchfor='&tv=only' end
end
if (getcmd(data,cmd6)==1) and (curUser.bOperator)then
if (arg=='smart') then sorts='&sort=smart' end
if (arg=='alpha') then sorts='&sort=alpha' end
if (arg=='chrono') then sorts='&sort=chrono' end
end
if (getcmd(data,cmd7)==1) and (curUser.bOperator) then
if (arg=='regexp') then type='&type=regexp' end
if (arg=='fuzzy') then type='&type=fuzzy' end
if (arg=='word') then type='&type=substring' end
end
if (getcmd(data,cmd8)==1) and (curUser.bOperator) then
toyear = "&from_year"..arg
end
if (getcmd(data,cmd9)==1) and (curUser.bOperator) then
toyear = "&to_year"..arg
end
if (strfind(strlower(data), strlower(cmd5))) then sett(curUser) end
end
end
function getcmd(data,md)
getmd=0
if (strfind(strlower(data), strlower(md))) then
arg = Get1Arg(data)
if (arg==nil) then
else
getmd=1
return getmd
end
end
end
function sett(target)
readfile(target,"settings.txt")
if (searchfor=='&tv=off') then
res = " Movie"
elseif (searchfor=='&tv=both') then
res = " Both"
elseif (searchfor=='&tv=only') then
res = " Tv"
end
wr(target,"Restrict is set for: "..res)
if (sorts=='&sort=smart') then
sort = " Best search matches first"
elseif (sorts=='&sort=alpha') then
sort = " Alphabetically"
elseif (sorts=='&sort=chrono') then
sort = " Chronologically"
end
wr(target,"Sort method is set for: "..sort)
if (type=='&type=regexp') then
typed = " Regular expression"
elseif (type=='&type=fuzzy') then
typed = " Fuzzy search"
elseif (type=='&type=substring') then
typed = " Word(s)"
end
wr(target,"Type of search is: "..typed)
fyear = gsub(fromyear, '&from_year','')
tyear = gsub(toyear, '&to_year','')
wr(target, "Bot searches from the year: "..fyear.." until "..tyear)
wr(target,'')
wr(target,"ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ")
end
send = " HTTP/1.1"..strchar(13, 10).."Host: us.imdb.com"..strchar(13, 10).."Connection: Close"..strchar(13, 10)..
"User-Agent: Mozilla/4.0 (blah blah blah whatever blah)"..strchar(13, 10)..strchar(13, 10)
function findNews(target,find)
wr(target,"_____________")
wr(target," Find something!")
wr(target,"ŻŻŻŻŻŻŻŻŻŻŻŻŻ")
wr(target,"Results for: "..find)
wr(target,"ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ")
file = ""..find..".txt"
if (openfile("imdb/"..file,"r")==nil) then
local line
local socket, err = connect("www.us.imdb.com",80)
writedonce=0
tob=nil
if not err then
socket:timeout(2)
err = socket:send("GET [URL]http://us.imdb.com/Tfuzzy?type=fuzzy&...rono&title=[/URL]"..find..send)
if not err then
writeto("imdb/"..find..".txt")
while not(line == "