mIRC Home    About    Download    Register    News    Help

Print Thread
Getting data from website #225624 06/09/10 04:13 PM
Joined: Apr 2010
Posts: 24
L
lassyakjedi Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2010
Posts: 24
Hey guys ,
I'm not much of an mirc coder at the moment, but have managed to create a decent bot smile
My query here is ,is there any way to link a particular website to my bot using scripts.Scripts that read data from the website and transfer it to my bot,when some user triggers my bot?
Basically i am making a bot that reads data from a text based gaming site (Take www.ruinsofchaos.com ,for example)

Example:
If there is a player named ABC on the website,
in my mirc window when i type '!link ABC'
i want my bot to display that particular players link.
something like
Code:
<user>!link ABC
<Bot>http://www.ruinsofchaos.com/stats.php?id=4358952

Last edited by lassyakjedi; 06/09/10 05:04 PM.
Re: Getting data from website [Re: lassyakjedi] #225629 06/09/10 07:43 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You may need to write a socket script to receive info from and send your request to a website.

Re: Getting data from website [Re: Tomao] #225863 12/09/10 05:12 AM
Joined: Apr 2010
Posts: 24
L
lassyakjedi Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2010
Posts: 24
Can u be a little bit more clear please, im new to mirc scripting so wont understand all the advanced stuff :p


Re: Getting data from website [Re: lassyakjedi] #225872 12/09/10 09:38 AM
Joined: May 2007
Posts: 37
C
Chessnut Offline
Ameglian cow
Offline
Ameglian cow
C
Joined: May 2007
Posts: 37
you could try this tutorial i wrote: http://forum.swiftirc.net/viewtopic.php?t=4378

Re: Getting data from website [Re: Chessnut] #225874 12/09/10 10:46 AM
Joined: Apr 2010
Posts: 24
L
lassyakjedi Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2010
Posts: 24
ok will go through that and give it a try smile
Also ,are all sockets written in remotes or Aliases ?

Last edited by lassyakjedi; 12/09/10 11:15 AM.
Re: Getting data from website [Re: lassyakjedi] #225879 12/09/10 01:56 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Everything is written in Remotes except aliases (and those can be written in remotes if prefixed with "alias"). Unless someone says otherwise, anything given on this forum will usually go into Remotes.


Invision Support
#Invision on irc.irchighway.net
Re: Getting data from website [Re: Riamus2] #225883 12/09/10 03:22 PM
Joined: Apr 2010
Posts: 24
L
lassyakjedi Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2010
Posts: 24
I gave my best shot after reading that tutorial...Great tutorial btw Chessnut smile
The beginning was easy enough to follow but i got stuck when i came to the SOCKREAD and SOCKCLOSE parts.

The game name is kingsofchaos as i said earlier
Quote:
Example:
If there is a player named ABC on the website,
in my mirc window when i type '!link ABC'
i want my bot to display that particular players link.
something like
Code:

<user>!link ABC
<Bot>http://www.kingsofchaos.com/stats.php?id=4358952 (just an example)


This is what i have managed to do so far.
Also all url of players are on the battlefield.php if that helps.(http://www.kingsofchaos.com/battlefield.php)

Code:
sockopen kocsock www.kingsofchaos.com 80
on $*:text:!link*:#: {
if ($sock(kocplay)) .sockclose kocplay
set %kocplayway $iif($left($1,1) == @, msg $chan, notice $nick)
sockopen kocplay www.kingsofchaos.com.com 80
}
on *:SOCKOPEN:kocplay: {
sockwrite -nt $sockname GET /lang/en/aff/kingsofchaos/title.ws HTTP/1.1
sockwrite -nt $sockname Host: www.kingsofchaos.com
sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:kocplay: {
  if ($sockerr) { halt }
  else {
  ...
  }
}

Any help will be appreciated smile
Thanks in advance!

Re: Getting data from website [Re: lassyakjedi] #226615 09/10/10 01:55 PM
Joined: Apr 2010
Posts: 24
L
lassyakjedi Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2010
Posts: 24
Anyone help please wink

Re: Getting data from website [Re: lassyakjedi] #226619 09/10/10 03:28 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Remove www. from your sockopen command (remove the duplicate one at the top), remove the duplicate .com from the sockopen command, and try HTTP/1.0 instead of 1.1. Also, if it's on battlefield.php, you should use that in your GET instead of what you have there now.


Invision Support
#Invision on irc.irchighway.net
Re: Getting data from website [Re: Riamus2] #226623 09/10/10 10:09 PM
Joined: Aug 2010
Posts: 69
N
N3M3S1S Offline
Babel fish
Offline
Babel fish
N
Joined: Aug 2010
Posts: 69
You may have to add certain functions so that it responds to that website's syntax.

Code:
on *:TEXT:!kings*:#: {
  %king.chan = $chan
  kingsofchaos $1-
}
alias kingsofchaos {
  ;add syntax to variable here
  %king.srch = $1-
  sockclose kings
  sockopen kings kingsofchaos.com 80
}
on *:SOCKOPEN:kings: {
  ;might have to add log-in as well
  sockwrite -n $sockname GET %king.srch HTTP/1.0
  sockwrite -n $sockname Host: www.kingsofchaos.com
  sockwrite -n $sockname Connection: Keep-Alive
  sockwrite -n $sockname Content-Type: text/html
  sockwrite -n $sockname $crlf
}
on *:SOCKREAD:kings: {
  sockread %kings

  ;may need to add $regex or $regml to sperate info from html.
  %king.num = 1

  ;change the number to appropriate number of information
  if (%king.num < 6) { 
    msg %king.chan %kings
    inc %king.num
  }
  elseif (%king.num >= 6) { sockclose king }
}
on *:SOCKCLOSE:king: { unset %king* }


Try something like that or improve upon this. I just threw it together as an example. One thing I noticed is that in order to do anything with that website you might have to have the bot log into the website through the sockets as well.


"There is no theory of evolution, only a list of creatures Chuck Norris allows to live."
Re: Getting data from website [Re: N3M3S1S] #226638 10/10/10 03:20 AM
Joined: Apr 2010
Posts: 966
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 966
So i've been looking into it, and here is the problem, due to them using multiple pages to return the result if the player being searched for is on any page other than the first, I can't make an easy way to get it :\

Last edited by FroggieDaFrog; 10/10/10 03:51 AM.

I am SReject
My Stuff
Re: Getting data from website [Re: N3M3S1S] #226651 10/10/10 06:41 PM
Joined: Apr 2010
Posts: 24
L
lassyakjedi Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Apr 2010
Posts: 24
Originally Posted By: N3M3S1S
You may have to add certain functions so that it responds to that website's syntax.

Code:
on *:TEXT:!kings*:#: {
  %king.chan = $chan
  kingsofchaos $1-
}
alias kingsofchaos {
  ;add syntax to variable here
  %king.srch = $1-
  sockclose kings
  sockopen kings kingsofchaos.com 80
}
on *:SOCKOPEN:kings: {
  ;might have to add log-in as well
  sockwrite -n $sockname GET %king.srch HTTP/1.0
  sockwrite -n $sockname Host: www.kingsofchaos.com
  sockwrite -n $sockname Connection: Keep-Alive
  sockwrite -n $sockname Content-Type: text/html
  sockwrite -n $sockname $crlf
}
on *:SOCKREAD:kings: {
  sockread %kings

  ;may need to add $regex or $regml to sperate info from html.
  %king.num = 1

  ;change the number to appropriate number of information
  if (%king.num < 6) { 
    msg %king.chan %kings
    inc %king.num
  }
  elseif (%king.num >= 6) { sockclose king }
}
on *:SOCKCLOSE:king: { unset %king* }


Try something like that or improve upon this. I just threw it together as an example. One thing I noticed is that in order to do anything with that website you might have to have the bot log into the website through the sockets as well.


Well i get This Error:
<&Btxx>!kings dark222
<~Bot1> <html>
<~Bot1> <head><title>400 Bad Request</title></head>
<~Bot1> <body bgcolor="white">
<~Bot1> <center><h1>400 Bad Request</h1></center>
<~Bot1> <hr><center>nginx/0.6.32</center>
<~Bot1> </body>
<~Bot1> </html>

Last edited by lassyakjedi; 10/10/10 06:42 PM.