I'm unsure of how to do this, I'm not great with using the HTTPService.
My code looks at the moment:
local id = 1 local httpservice = game:GetService("HttpService") local url = "http://rproxy.pw/users/" ..id.. "/profile" local cut = [[<p class="stat%-title">Forum Posts</p><p class="rbx%-lead">%d+</p>]]
You want to use the string.match
method.
First of all, you want to use parenthesis in your "cut", or your string pattern to tell which part you want to grab (I'm also going to fix it for you here since it was designed to grab the forum posts):
local cut = [[<p class="stat%-title">Join Date</p>%S+<p class="rbx%-lead">(.-)</p>]]
So. what's going on here?
Well, here's an example of how the HTML would look:
... <p class="stat-title">Join Date</p> <p class="rbx-lead">1/5/2013</p> ...
Well, obviously you want to extract "1/5/2013" here. The most obvious solution is to use the pattern <p class="rbx%-lead">(.-)</p>
. %
means that the following character will be "escaped", so that Lua ignores its special behavior. (.-)
means "match as few characters as possible", which would match 1/5/2013 since it also wants to find the <p class...
string before (.-)
and </p>
after it.
But here's the problem: There are other things matching that pattern, too, such as the place visits and forum posts. You'll have to specify what you REALLY want to find.
That's why I added the beginning: <p class="stat%-title">Join Date</p>%S+
This obviously matches the code for the label. %S+ means that it should also match all the whitespace, since there are newlines and stuff after it.
Now, you'll have to request the page and match it:
local id = 1 local httpservice = game:GetService("HttpService") local url = "http://rproxy.pw/users/" ..id.. "/profile" local html = httpservice:GetAsync(url) -- added local cut = [[<p class="stat%-title">Join Date</p>%S+<p class="rbx%-lead">(.-)</p>]] -- changed local joindate = html:match(cut);
For further information:
* http://wiki.roblox.com/index.php?title=API:Class/HttpService
* http://lua-users.org/wiki/PatternsTutorial
* http://lua-users.org/wiki/StringLibraryTutorial
Also, I haven't tested the code, but it should work.
function getJoinDate(id) local link = "http://www.rproxy.pw/users/" ..id.. "/profile"; local cut = [[<p class="stat-title">Join Date</p><p class="rbx-lead">%.+</p>]]; local serv = game.HttpService; local html; local success,msg = pcall(function() html = serv:GetAsync(link,false); end); if success then --local find = html:match(cut); if html then print(html); else print("Cannot Get Join Date"); end; else print("Cannot Get Join Date (Access denied to ROBLOX website)"); end; end; getJoinDate(21467784);
The above code will go and copy the whole webpage. xD I did this and dropped it into notepad++ and searched for part of my join date (2011). It found this in there. So if you found a way to go and cut the join date out of it that should in theory work.