For example, if I use http.Fetch on certain webpages it should be returning a HUGE string of http code. However, it seems as if I either can't use all of this string or it's not all there. When I use functions like string.find it won't find something that's clearly there when I look at the http in the browser myself. I think this is because it's only searching through maybe the first few thousand characters in the string. So how can I get it to use the whole string?
Code?
Ok, so for fun and kind of 'research' purposes, I was trying to make a simple script that would search for keywords in posts on a facepunch thread.
[lua]
local threadURL = 'http://facepunch.com/showthread.php?t=1229902' //Without '&page=#'
local postStart = 'class="postcontent restore "'
local postEnd = '</blockquote>'
local pageNum = 1
local searchTerms = {
"day","night","engine.LightStyle","fog","sun","moon"
}
local lastPos = 1
local function SkimPage(httpCode)
local start = string.find(httpCode, postStart, lastPos, true) //This right here keeps returning nil, even though I've looked in the http myself and have seen postStart (class="postcontent restore ")
if !start then return end
local stop = string.find(httpCode, postEnd, start, true)
if !stop then return end
local content = string.sub(httpCode, start + string.len(postStart) + 2, stop - 1)
for _,word in pairs(searchTerms) do
if string.find(content, word) then
print("Content found!")
//Export to txt or something
break
end
end
lastPos = stop
SkimPage(httpCode)
end
for i = 1,pageNum do
http.Fetch(threadURL.."&page="..i, SkimPage)
end
[/lua]
You can't access facepunch as a guest IIRC.
[QUOTE=Robotboy655;40856754]You can't access facepunch as a guest IIRC.[/QUOTE]
Oh man, you're right. I just checked it and it's the http code from the "Sorry - You can't view this page!" page. Oh well, guess I'll just have to manually skim through it.
Sorry, you need to Log In to post a reply to this thread.