Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Problems with matching a specific line in a page's HTML?

NOTE: Please don't mark this as a duplicate (which it probably isn't, because the last time I got a question marked as a "duplicate", it wasn't, and I was linked to an irrelevant question with an irrelevant answer). SH's search is pretty useless, or my question has not been asked before with a relevant title.

Now, the string I am trying to find in the page's HTML is this:

local cut = [[<p class="rbx-lead">%.+</p>]]

But for some reason, this is returning nil, even though %.+ could be anything (E.G: "","1","aBc", etc).

Can someone please tell me why?

I am using rproxy.pw for this, and maybe it's HTML returned from a script is different to the usual ROBLOX.com?

From what I have gathered, I could have done this: %.+ or this: (%.+). I have tried both, and both don't work. Also, I know that actually establishing the connect to the website isn't the problem, because I have printed the entire page's code.

Also, the specific page I am using to get my information is: http://rproxy.pw/users/" ..id.. "/profile

Someone asked for more code, so I will provide you guys with the entire function I am using:

function getJoinDate(id)
	local link = "http://rproxy.pw/users/" ..id.. "/profile"
	local cut = [[<p class="rbx-lead">%.+</p>]] --<p class="stat-title">Join Date</p> multi-line help?
	local html
	local success,msg = pcall(function() html = serv:GetAsync(link,false) end)
	if success then 
		print("works")
		local find = html:match(cut)
		if find then
			print("found")
			return find
		else
			return "Cannot Get Join Date"
		end
	else
		return "Cannot Get Join Date"
	end
end

1 comment

0

Can you show a bit more code?

1 answer

Again, for the third time -- - is a special character. You need to use %-.

x-y matches xxxy, not x-y.


Other Problems

. won't match newlines. Since the paragraph is split onto multiple lines, the pattern won't work.

You can use [%S%s] to mean match anything (which is basically just . plus newlines), but then that will give you way more than you want, because it will pick a random </p> way later to stop at.

You can use [%S%s]- to make it stop sooner, but it's probably more straightforward to just use [^<]+ to mean until the next tag.

That makes your pattern this:

[[<p class="rbx%-lead">([^<]+)</p>]] 

Formatting

Instead of making the local html variable, you can instead just return from your function:

    local success, html = pcall(function() return serv:GetAsync(link, false) end)

This discussion is preserved as it was. New answers, comments, and votes are closed.