ID:159637
 
How could I use findtext or any proc actually to find out if a BYOND member page is real. Like I'm trying to make it say,
"Sorry this key does not exist". Perhaps there is a way I could?
Import the page you want(for example byond.com/members/thisdoesntexist) and compare it to the main page of the blogs (byond.com/members).

If it's the same, the key doesn't exist.
In response to Andre-g1
I tried it but I need a core difference, like some text that stands out that wouldn't be anywhere, unless you're suggesting I have a very, very, extremely long if proc.
You could actually compare text+html, as in say you've imported the source and found that it says

//just for readability
<div class="big_box">
<p class="title">Recent Blog Posts</p>
<div style="text-align:center; margin: 1em;">
<b style="margin:0 1em">All</b>
<a href="http://www.byond.com/members/?filter=review" style="margin:0 1em">Reviews</a>

<a href="http://www.byond.com/members/?filter=poll" style="margin:0 1em">Polls</a>
</div>


Then the chances are that they're on the member page since the page was not found. Something like that as I doubt ANY page will have that.

Just findtext for something like that. Things that don't change on the members page.
In response to Haywire
Would I have to html_decode the page first?

var/website = world.Export("http://byond.com/members/[named]")
var/Text = {"<div class="big_box">
<p class="title">Recent Blog Posts</p>
<div style="text-align:center; margin: 1em;">
<b style="margin:0 1em">All</b>
<a href="http://www.byond.com/members/?filter=review" style="margin:0 1em">Reviews</a>

<a href="http://www.byond.com/members/?filter=poll" style="margin:0 1em">Polls</a>
</div>"}

//later on

if(findtext(html_decode("[website]","[Text]"))
In response to Choka
Arghh, I don't remember correctly, but if you save the exported data into a list you can access the source via listname["CONTENT"] or listname["CONTENTS"]. Correct my if I'm wrong.
In response to Haywire
If I converted it into a list then I'd be using find() instead of findtext() and I'd also be doing something COMPLETELY different.
In response to Choka
Noo, if you made it a list you can access the "CONTENT" index. Hold on, give me a minute I'll check something.
In response to Choka
This seems to work:

var
compare = "&lt;p class=&#34;title&#34;&gt;Recent Blog Posts&lt;/p&gt;"
client
verb
CheckMember(key = "Haywire" as text)
var/list/codes = world.Export("http://www.byond.com/members/[key]")
if(findtext(html_encode(file2text(codes["CONTENT"])),compare))
src << "[key] is not an existing key!"
else
src << "[key] is an existing key!"

In response to Haywire
Thanks a trillion! I've been trying on that for a long time.
In response to Haywire
It really doesn't matter if he "made it a list" (assuming "define its var as of /list type"), since it gets set into a list anyway and accessing an index or key doesn't require any typecasting at compile-time. So you could do the same anyway:
var/website = world.Export(...)
usr << website["CONTENT"]

You could define the website var as an /obj if you felt like it, it doesn't matter. It doesn't affect the data of the var.
In response to Kaioken
Thank you for the information.
You can easily do this by using the text-formatted member page, if the content-type header is plain text they exist, if the content-type header is html they don't (as it would return the HTML front page).
mob
verb
MemberCheck(keyname as text)

var
list/st = world.Export("http://byond.com/members/[ckey(keyname)]?format=text")

if(!st)
usr << "Unable to connect to the BYOND site."
return

var/content_type = st["CONTENT-TYPE"]

if(findtext(content_type,"text/plain")) usr << "[keyname] exists!"

else usr << "[keyname] does not exist!"