mIRC Home    About    Download    Register    News    Help

Print Thread
sockets, grabbing a specific item for PHP file #205064 11/10/08 12:25 PM
Joined: Sep 2008
Posts: 12
D
Demolution Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Sep 2008
Posts: 12
Hi guys,

Just wondering how to grab a specific item like...

Quote:
D: 52.38 kb/s | U: 10.98 kb/s


if mirc.php displays that - how do i grab just the "U: XX.X lb/s" area, code below which grabs the whole thing for mirc.php

Code:
alias meh sockopen mirc domain.com 80

on *:sockopen:mirc:{
  sockwrite -n $sockname GET /mirc.php HTTP/1.1
  ; This is telling the socket to connect to the specific page, using "GET".
  sockwrite -n $sockname Host: domain.com $+ $crlf $+ $crlf
  ; This states the host once again.
}

on *:sockread:mirc:{
  if $sockerr { 
    echo 4 -a Error $v1 on $sockname : $sock($sockname).wserr ( $sock($sockname).wsmsg ) 
    return 
  }
  var %x
  sockread %x
  while $sockbr {
    if ( D: * iswm %x ) { echo -a %x }
    ;echo -a %x
    sockread %x
  }
  sockread -f %x
  ;echo -a %x
  if ( D: * iswm %x ) { echo -a %x }
}


I also wondered how do i grab a list of all files displayed on a website eg. "www.domain.com/list/" and getting rid of those lame html languages/codes/

Re: sockets, grabbing a specific item for PHP file [Re: Demolution] #205065 11/10/08 01:07 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
To get rid of the html codes, I suggest using a little custom alias that I've seen in several socket scripts called htmlfree.

Here's the alias, just call it using $htmlfree($1-)
Code:
alias -l htmlfree {
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;)
  return %x
}


I have no idea who wrote that originally, but appropriate credits/kudos to the person that did.

Re: sockets, grabbing a specific item for PHP file [Re: Demolution] #205068 11/10/08 05:48 PM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Doesn't help us any when you do not give the proper domain to where we can connect to help you grab this info has many times are different and some even require cookies.

Without an actual domain (real example) we cannot help you further.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Re: sockets, grabbing a specific item for PHP file [Re: Lpfix5] #205069 11/10/08 09:33 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
We can't? I can... All you really need is the relevant html snippet from the page, not the URL.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: sockets, grabbing a specific item for PHP file [Re: argv0] #205085 12/10/08 02:28 AM
Joined: Sep 2008
Posts: 12
D
Demolution Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Sep 2008
Posts: 12
Code:
alias meh sockopen mirc rebellion.net.au 80

on *:sockopen:mirc:{
  sockwrite -n $sockname GET /mirc.php HTTP/1.1
  ; This is telling the socket to connect to the specific page, using "GET".
  sockwrite -n $sockname Host: rebellion.net.au $+ $crlf $+ $crlf
  ; This states the host once again.
}

on *:sockread:mirc:{
  if $sockerr { 
    echo 4 -a Error $v1 on $sockname : $sock($sockname).wserr ( $sock($sockname).wsmsg ) 
    return 
  }
  var %x
  sockread %x
  while $sockbr {
    if ( D: * iswm %x ) { echo -a %x }
    ;echo -a %x
    sockread %x
  }
  sockread -f %x
  ;echo -a %x
  if ( D: * iswm %x ) { echo -a %x }
}


here you go

Re: sockets, grabbing a specific item for PHP file [Re: argv0] #205092 12/10/08 06:30 PM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
lol true, but if the website needs to handle cookies to dump the HTML in true form then your out of luck if you give a piece of code.


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }