mIRC Homepage

Using Sockets.

Posted By: Mail

Using Sockets. - 03/01/07 11:08 PM

I am trying to get information from a web site, my own, off of a forum where all the material is hidden for various reasons. Then I am going to display this information in a particular channel via mIRC. My problem is auth'ing to the server. Any ideas on how this can be accomplished. The forum uses phpbb2 and there is a login link on main index page.

Any assistance on this would be appreciated.
Posted By: Riamus2

Re: Using Sockets. - 03/01/07 11:40 PM

FiberOPtics wrote me a nice script for logging in and posting to a phpBB forum. You can find it here (note that the search brought me to a place further down the thread... you may want to scroll to the top and read from the beginning).

Now, this is for POSTING, but it logs you in, which is what you are trying to do. If you take the part that logs you in, then you can do a standard socket script to sockread the page(s) that you need. Keep in mind that everywhere that mentions by domain (kakkoiitranslations.net) will need to be changed to YOUR domain. Also, don't forget to change the login info.
Posted By: Mail

Re: Using Sockets. - 03/01/07 11:52 PM

Thanks I will give it a try.
Posted By: Mail

Re: Using Sockets. - 04/01/07 02:25 AM

Ok I can get logged in alright, but for some reason the retrieval script isnt retrieving. The post part isnt working exactly as well. I made all the suggested changes and still no go. I can however login. So I am thinking I need to use php based commands for retrieving as well.
Posted By: Riamus2

Re: Using Sockets. - 04/01/07 02:43 AM

Well, you'll need a GET in your sockopen event, similar to this:

on *:sockopen:socketname: {
  sockwrite -n $sockname get /path/page.php HTTP/1.0

First, you'll have to login before doing this, though. You should be able to find the right place to put the GET line. If not, post what you have after you've tried.

You will also need a sockread event to gather the data from the page:
on *:sockread:socketname: {
  if ($sockerr) {
    echo -a Error.
  else {
    var %temptext
    sockread %temptext
    if (*<td style="width: 20%;"> iswm %temptext) {
      var %data = %temptext

That's just a sample of the start of a sockread event. The IF section at the end should be changed to match whatever line(s) you want the data from and you may need to $gettok your line when setting the variable to get just the data you need. You can put multiple IF lines in there (add to the end... probably with ELSEIF instead of just IF) to get data from other lines that have a different matchtext.

So, after logging in, you need to GET the page, then sockread the page and parse it for the data you want.
© 2020 mIRC Discussion Forums