Page 1 of 1

Searching webpages

Posted: April 6th, 2012, 9:45 pm
by BobKare
Hello.

I've wrote a command who searches a website for a decent word.
To avoid long, bad explanations, take a look at the code:

Code: Select all

string word = cmd.NextAll();

string webpageData;
using (System.Net.WebClient webClient = new System.Net.WebClient())
    webpageData = webClient.DownloadString("http://www.cnn.com");
if (webpageData.Contains(word))
{
    player.Message("Positive");
    return;
}
else
{
    player.Message("Negative");
    return;
}
For now, it doesn't do anything but returning either Positive, if the website contains the word, or Negative, if it doesn't.

What I'm trying to make, is a very simple auto-rank system, whom promotes you to a preset rank if your Minecraft username is on the page.
Which means that you may link it to search a member list, like the one on these forums, and promote you if you registered.

However, the promoting isn't hard to fix.
What's my problem, is the member lists, which is sorted out in a table.
It doesn't accept the input, which is the word (username), whom is sorted in a table.
I guess, because it's sorted in a table :p

Are there any ways to solve this?

Thanks for your help,

-BobKare

Re: Searching webpages

Posted: April 6th, 2012, 11:44 pm
by LiamRayStanley
is this specific to any webpage source like html or php?

Re: Searching webpages

Posted: April 7th, 2012, 12:01 am
by fragmer
PHP scripts run server-side. Content that's served to web browsers is always HTML, regardless of what technologies the server uses to produce it.

Also note that this command won't work with shitty websites like Twitter that serve content dynamically via AJAX.

Re: Searching webpages

Posted: April 7th, 2012, 2:29 am
by LiamRayStanley
i didnt think about that lol -.-

Re: Searching webpages

Posted: April 7th, 2012, 10:51 am
by BobKare
Well, you know how I can make this read what's in the tables?

Re: Searching webpages

Posted: April 7th, 2012, 9:07 pm
by Jonty800
Why do you want this done through a html page? Surely it will be easier to just use a .txt file? You could then upload the txt file to your website and then hook the command up to http://mywebsite.com/autorank.txt

Re: Searching webpages

Posted: April 7th, 2012, 9:10 pm
by BobKare
Then I need to load the data of the members.php page into that txt file.

I want them to get ranked by registering on the forums.

Re: Searching webpages

Posted: April 10th, 2012, 9:37 pm
by Jonty800
Myabe use a Regex, such as: http:\/\/.*?\.(?:x?html|php?wsdl|aspx)

var word = "Jonty800";
var match = Regex.Match(word, @"http:\/\/.*?\.(?:x?html|php?wsdl|aspx)");
Server.Message(match.Success? match.Groups[0].Value : "Not found");

Re: Searching webpages

Posted: April 11th, 2012, 10:38 pm
by fragmer
Jonty800 wrote:var match = Regex.Match(word, @"http:\/\/.*?\.(?:x?html|php?wsdl|aspx)");
That checks if "word" contains a URL string.