mIRC Home    About    Download    Register    News    Help

Print Thread
Sockets again... #175016 16/04/07 12:17 AM
Joined: Jan 2007
Posts: 22
D
Deele Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Jan 2007
Posts: 22
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
Re: Sockets again... [Re: Deele] #175029 16/04/07 06:59 AM
Joined: Feb 2005
Posts: 342
R
Rand Offline
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
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.

Re: Sockets again... [Re: Rand] #175055 16/04/07 10:18 PM
Joined: Jan 2007
Posts: 22
D
Deele Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Jan 2007
Posts: 22
Helped... thanks wink


Deele /SCRIPTWORKS/

LV | ENG | RU