News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.


Post Reply  Post Thread 
How to advertise?
Author Message
asafp
Member
***


Posts: 81
Group: Registered
Joined: Jan 2008
Status: Offline
Reputation: 0
Post: #1
RE: How to advertise?

I fixed the problem with headers. I had an ipairs loop to process them. I changed it to pairs and everything is cool. Greenhorn mistake.

This luasocket http get request program demonstrates exception occurs if website doesn't exit.

function GetHtml(urlin)
local http=require('socket.http')
local url=require('socket.url')
local ltn12 = require("ltn12")
local mime = require("mime")
local urlname=urlin
local t={}
--print (os.date(),urlname)
local r, c, h, w = http.request {
method = "GET",
headers = {["Useragent"]='Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11',
["Content-Type"] = "application/x-www-form-urlencoded",
["Connection"]="Keep-Alive"},
url = urlname,
redirect = true,
sink = ltn12.sink.table(t)
-- sink = ltn12.sink.file(io.stdout)
}
print ('r=',r)
print ('c=',c)
print ('w=',w)
for k,v in pairs(h) do
print (k,v)
end
return table.concat(t), c, h
end
x=GetHtml('http://whatismyip.com')
x=GetHtml('http://iamabogusurl.com')

01-25-2008 06:12 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
How to advertise? - mikshaw - 01-21-2008, 12:42 PM
RE: How to advertise? - iGame3D - 01-21-2008, 05:31 PM
RE: How to advertise? - JohnMurga - 01-21-2008, 05:51 PM
RE: How to advertise? - asafp - 01-23-2008, 04:19 AM
RE: How to advertise? - JohnMurga - 01-24-2008, 07:02 PM
RE: How to advertise? - iGame3D - 01-23-2008, 08:45 AM
RE: How to advertise? - asafp - 01-25-2008 06:12 AM
RE: How to advertise? - asafp - 01-25-2008, 06:27 AM
RE: How to advertise? - asafp - 01-25-2008, 06:52 AM
RE: How to advertise? - mikshaw - 01-25-2008, 07:33 AM
RE: How to advertise? - asafp - 01-25-2008, 08:42 AM
RE: How to advertise? - mikshaw - 01-25-2008, 09:41 AM
RE: How to advertise? - JohnMurga - 01-26-2008, 02:21 AM
RE: How to advertise? - JohnMurga - 01-26-2008, 07:03 AM
RE: How to advertise? - mmburke - 01-31-2008, 08:23 AM
RE: How to advertise? - mikshaw - 01-31-2008, 11:11 AM
RE: How to advertise? - iGame3D - 01-31-2008, 08:30 PM
RE: How to advertise? - mmburke - 02-01-2008, 03:04 AM
RE: How to advertise? - asafp - 02-01-2008, 04:06 AM
RE: How to advertise? - JohnMurga - 02-01-2008, 04:18 AM
RE: How to advertise? - JohnMurga - 02-01-2008, 04:08 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: