Searching webpages

For all mod-related questions and custom code.
Post Reply
BobKare
Offline
Posts: 279
Joined: May 26th, 2011, 2:15 pm

Searching webpages

Post 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

User avatar
LiamRayStanley
OP
Offline
Posts: 151
Joined: February 9th, 2012, 2:09 pm
Contact:

Re: Searching webpages

Post by LiamRayStanley »

is this specific to any webpage source like html or php?
<+FCB>Arvarna: i think your banhammer needs a downgrade

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Searching webpages

Post 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.

User avatar
LiamRayStanley
OP
Offline
Posts: 151
Joined: February 9th, 2012, 2:09 pm
Contact:

Re: Searching webpages

Post by LiamRayStanley »

i didnt think about that lol -.-
<+FCB>Arvarna: i think your banhammer needs a downgrade

BobKare
Offline
Posts: 279
Joined: May 26th, 2011, 2:15 pm

Re: Searching webpages

Post by BobKare »

Well, you know how I can make this read what's in the tables?

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: Searching webpages

Post 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
You cannot use certain BBCodes: [img].

BobKare
Offline
Posts: 279
Joined: May 26th, 2011, 2:15 pm

Re: Searching webpages

Post 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.

Jonty800
Offline
Posts: 280
Joined: August 21st, 2011, 6:31 am
Location: United Kingdom
Contact:

Re: Searching webpages

Post 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");
You cannot use certain BBCodes: [img].

User avatar
fragmer
fCraft Developer
Offline
Posts: 1386
Joined: May 21st, 2011, 10:53 pm

Re: Searching webpages

Post by fragmer »

Jonty800 wrote:var match = Regex.Match(word, @"http:\/\/.*?\.(?:x?html|php?wsdl|aspx)");
That checks if "word" contains a URL string.

Post Reply