mIRC Home    About    Download    Register    News    Help

Topic Options
#175016 - 16/04/07 01:17 AM Sockets again...
Deele Offline
Ameglian cow

Registered: 27/01/07
Posts: 22
Loc: Europe, Latvia, Riga
I don't get. Trying to connect to
http://www.capitalfm.lv/inc/radio.php
page...
Code:
alias capitalfm {
  if (%capitalfm.delay == 1) {
    .notice $2 Wait a moment...
    return
  }
  set -u5 %capitalfm.delay 1
  sockopen capitalfmsock www.capitalfm.lv 80
}
on *:sockopen:capitalfmsock: {
  sockwrite -n $sockname GET /inc/radio.php HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
  sockwrite -n $sockname Host: www.capitalfm.lv
  sockwrite -n $sockname Accept-Language: en-us
  sockwrite -n $sockname Accept-Encoding: gzip, deflate
  sockwrite -n $sockname Accept: */* $+ $crlf $+ $crlf
}
on *:sockread:capitalfmsock: {
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    if (ON isin %temptext) {
      capitalfm-result %temptext
    }
  }
}
alias capitalfm-result {
  echo -a $1
  unset %capitalfm.*
  sockclose capitalfmsock
}

It just returns:
Quote:
HTTP/1.0 200 OK
Date: Mon, 16 Apr 2007 00:12:28 GMT
Server: Apache
Set-Cookie: SESSID=74026a413bebfa41be1d18d2ec8c5e31; path=/
Content-Type: text/html
X-Cache: MISS from 172.16.0.1
Via: 1.0 172.16.0.1:80 (squid/2.6.STABLE9)
Connection: close


I don't get, why it doen't, that, what I want laugh cry
_________________________
Deele /SCRIPTWORKS/

LV | ENG | RU

Top
#175029 - 16/04/07 07:59 AM Re: Sockets again... [Re: Deele]
Rand Offline
Fjord artisan

Registered: 28/02/05
Posts: 342
Code:
alias someradio {
  if ($sock(someradio)) { sockclose someradio }
  sockopen someradio www.capitalfm.lv 80
  sockmark someradio /inc/radio.php
}
on *:sockopen:someradio:{
  var %% = sockwrite -n $sockname , %link = $sock($sockname).mark
  %% GET %link HTTP/1.0
  %% Host: www.capitalfm.lv
  %%
}
on *:sockread:someradio:{
  if ($sockerr) return
  var %s | sockread -f %s
  while ($sockbr) {
    if (ON isincs %s) {
      tokenize 32 $replace(%s, ,$chr(32))
      echo -a :: Capitalfm :: $1-
    }
    sockread -f %s
  }
}


Should do what you want. Modify it to suite your needs.

Top
#175055 - 16/04/07 11:18 PM Re: Sockets again... [Re: Rand]
Deele Offline
Ameglian cow

Registered: 27/01/07
Posts: 22
Loc: Europe, Latvia, Riga
Helped... thanks wink
_________________________
Deele /SCRIPTWORKS/

LV | ENG | RU

Top