It is currently October 19th, 2018, 10:54 pm


All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Searching webpages
PostPosted: April 6th, 2012, 9:45 pm 

Joined: May 26th, 2011, 2:15 pm
Posts: 279
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:
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


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Searching webpages
PostPosted: April 6th, 2012, 11:44 pm 
OP
User avatar

Joined: February 9th, 2012, 2:09 pm
Posts: 151
is this specific to any webpage source like html or php?

_________________
<+FCB>Arvarna: i think your banhammer needs a downgrade


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Searching webpages
PostPosted: April 7th, 2012, 12:01 am 
fCraft Developer
User avatar

Joined: May 21st, 2011, 10:53 pm
Posts: 1386
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Searching webpages
PostPosted: April 7th, 2012, 2:29 am 
OP
User avatar

Joined: February 9th, 2012, 2:09 pm
Posts: 151
i didnt think about that lol -.-

_________________
<+FCB>Arvarna: i think your banhammer needs a downgrade


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Searching webpages
PostPosted: April 7th, 2012, 10:51 am 

Joined: May 26th, 2011, 2:15 pm
Posts: 279
Well, you know how I can make this read what's in the tables?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Searching webpages
PostPosted: April 7th, 2012, 9:07 pm 

Joined: August 21st, 2011, 6:31 am
Posts: 280
Location: United Kingdom
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].


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Searching webpages
PostPosted: April 7th, 2012, 9:10 pm 

Joined: May 26th, 2011, 2:15 pm
Posts: 279
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Searching webpages
PostPosted: April 10th, 2012, 9:37 pm 

Joined: August 21st, 2011, 6:31 am
Posts: 280
Location: United Kingdom
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].


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Searching webpages
PostPosted: April 11th, 2012, 10:38 pm 
fCraft Developer
User avatar

Joined: May 21st, 2011, 10:53 pm
Posts: 1386
Jonty800 wrote:
var match = Regex.Match(word, @"http:\/\/.*?\.(?:x?html|php?wsdl|aspx)");

That checks if "word" contains a URL string.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net