PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: TyShkan on 14 August, 2004, 22:23:48

Title: site-reader
Post by: TyShkan on 14 August, 2004, 22:23:48
who can give me a script, that can connect to site and read information from them, then converting
to \n, etc. and save the information to the file news.txt...
Who can help?
Title:
Post by: Herodes on 15 August, 2004, 02:18:11
Since there are unlimited ways to provide data through html or any other type of web document a universal site reader is not possible ... even if it is it wouldn't be practical ...
I would say that having a standard html data structure could make this possible ....
Pls provide an address from where you need the news to be read from....

What u asked for would be ok with

gsub(data, "
", "\r\n") ... maybe :)
Title:
Post by: TyShkan on 15 August, 2004, 11:20:58
i'm reading news from special-formatted page, which generated php-script, this page is now not accessible...i'm don't finish works on it...how i can grab data from site?
Title:
Post by: Herodes on 15 August, 2004, 11:58:11
You can find c h i l l a's Exchange Converter script here (http://board.univ-angers.fr/thread.php?threadid=596&boardid=12)
Scroll down to the GetRates function ...
It gives a nice example of how to connect to a site and get specific data out of it ...
although personally I have never tried scripting smth like that ... :)
Title:
Post by: TyShkan on 16 August, 2004, 12:12:39
--to deleting--
Title:
Post by: TyShkan on 16 August, 2004, 12:13:56
--to deleting--
Title:
Post by: Herodes on 16 August, 2004, 12:44:31
I see now that u have been trying to grab
Hi!))\n\nOooOoooOooo
dont forget to try also with "\r\n" apart from "\n"
Title:
Post by: TyShkan on 16 August, 2004, 12:56:19
Hi! Using this script I have written own=)
GETHTML = "GET /lol.php HTTP/1.1\r\nHost: xhub.ultranet.ru\r\nUser-Agent: Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"

Bot = "::[X]::"

function GetNews(user)
local socket, err = connect("xhub.ultranet.ru", 80)
local code = ""
if not err then
socket:timeout(2)
socket:send(GETHTML..strchar(13,10))
local line = ""
while not err do
line, err = socket:receive("*l")
code = code..line
end
socket:close()
end
socket:close()
user:SendData(Bot, code)
end

function DataArrival(user, data)
if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(Bot)) == "$To: "..Bot) then
data = strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "!go") then
GetNews(user)
end
end
end

Page is now accessible at http://xhub.ultranet.ru/lol.php and contains Hi!))\r\n\r\nOooOoooOooo
When i writing !go, this script return
HTTP/1.1 200 OKDate: Mon, 16 Aug 2004 10:24:33 GMTServer: Apache/1.3.29 (Unix) mod_become/1.3 PHP/4.3.5 mod_layout/3.2X-Powered-By: PHP/4.3.5Connection: closeTransfer-Encoding: chunkedContent-Type: text/html14 Hi!))\r\n\r\nOooOoooOooo0
What i would change, that the script would understand "\n", etc and showing Hi!))\r\n\r\nOooOoooOooo as Hi!))

OooOoooOooo
in dc?
Thanks ;)