mIRC Home    About    Download    Register    News    Help

Print Thread
#40636 09/08/03 04:28 AM
Joined: Feb 2003
Posts: 143
N
naki Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Feb 2003
Posts: 143
is there a way to get the <title>stuff</title> from this

<html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title><style><!


#40637 09/08/03 04:33 AM
P
pheonix
pheonix
P
//echo -a $remove(<html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title><style><!,<html>,<head>,<meta http-equiv="content-type", content="text/html; charset=ISO-8859-1">style><!,content="text/html; charset=ISO-8859-1">,<style><!)

#40638 09/08/03 04:34 AM
C
codemastr
codemastr
C
.echo -q $regex(%thetext,.*(<title>.*</title>).*)
.echo -a The title is: $regml(1)

#40639 09/08/03 04:34 AM
P
pheonix
pheonix
P
or that :tongue:

#40640 09/08/03 05:43 AM
Joined: Feb 2003
Posts: 143
N
naki Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Feb 2003
Posts: 143
Code:
alias sbot_web_open { sockopen sbot_web $gettok(%sbot_other,2,32) 80 }

on 1:sockopen:sbot_web: { 
  .sockwrite -n $sockname GET / HTTP/1.1
  .sockwrite -n $sockname Host: comcast.net
  .sockwrite $sockname $crlf  
  .timerweb 1 3 sockclose sbot_web
} 

on 1:sockread:sbot_web: {
  sockread -f %sb_raw
  ;echo @sbot 04 %sb_raw
  if (%sbot_web_title) {
    if (&lt;title&gt; isin %sb_raw) { 
      set %sbot_web_ts $regex(%sb_raw,.*(&lt;title&gt;.*&lt;/title&gt;).*)
      set %sbot_web_ts $remove($regml(1),&lt;title&gt;,&lt;/title&gt;)
      sbot_com privmsg %sbot_chan : $+ %sbot_nick $+ : [title: $gettok(%sbot_other,2,32) $+ $chr(93) %sbot_web_ts
      .sockclose sbot_web
      unset %sbot_web_title | unset %sbot_web_ts
    }

  } 
}


Sometimes when I do

title www.somesite.com or like www.sl.somesite.com

I get this

-
* /sockwrite: 'sbot_web' not connected (line 92, sbot.txt)
-

is there a way to fix this?

#40641 09/08/03 07:10 AM
Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
.sockwrite -n $sockname Host: comcast.net

That line must match the website your querying. Also your query may not contain the http:// preifx or / suffix. must be a "clean" url such as www.google.com not http://www.google.com If you were to query google, you must use Host: www.google.com, not comcast.

#40642 09/08/03 07:16 AM
Joined: Feb 2003
Posts: 143
N
naki Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Feb 2003
Posts: 143
is there a way to make that not show up then? I used .sockwrite but it still shows.

#40643 09/08/03 07:21 AM
Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
paste ur script again highlighting the cline you have a problem with pls

#40644 09/08/03 10:01 AM
Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Help file:
$sockerr
$sockerr is set to a value after each socket command/event and must be checked after each socket command and before processing an event to see if an error occurred.


So the on SOCKOPEN might trigger but only to report an error (which should be checked with $sockerr), in which case you won't be able to /sockwrite.

#40645 09/08/03 05:07 PM
Joined: Feb 2003
Posts: 143
N
naki Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Feb 2003
Posts: 143
nm, I tried to see if I could use ^ and it worked. Thanks though.

Code:
on ^1:sockopen:sbot_web: { 
  .sockwrite -n $sockname GET / HTTP/1.1 | haltdef
  .sockwrite -n $sockname Host: $gettok(%sbot_other,2,32)
  .sockwrite $sockname $crlf  
  .timerweb 1 3 sockclose sbot_web
} 

#40646 09/08/03 06:25 PM
C
codemastr
codemastr
C
Not related to your question but, don't do:
set %sbot_web_ts $regex(%sb_raw,.*(<title>.*</title>).*)
set %sbot_web_ts $remove($regml(1),<title>,</title>)


You said you wanted the <title></title> to remain, thats why I made it do that, if you really didn't want that then just use:

set %sbot_web_ts $regex(%sb_raw,.*<title>(.*)</title>.*)
set %sbot_web_ts $regml(1)

That way you don't need the $remove.

#40647 09/08/03 08:21 PM
Joined: Feb 2003
Posts: 143
N
naki Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Feb 2003
Posts: 143
Thanks. At first that is what I just wanted. To get the <title>stuff</title> from things like that so I could use $remove, but since your way is cleaner I'm going to use that. I dont know anything about $regex

#40648 09/08/03 09:31 PM
Joined: Feb 2003
Posts: 143
N
naki Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Feb 2003
Posts: 143
Now I've ran into another problem. When I do title www.somesite.com, it the bot doesnt even say anything anymore.

Here is the code.

Code:
on *:signal:sbot_read:{
  if ((join == $3) || (part == $3) || (privmsg == $3) || (notice == $3) || (topic == $3) || (kick == $3) || (mode == $3) || (quit == $3)) {
    set %sbot_nick $remove($gettok($2,1,33),:)
    set %sbot_addy $gettok($2,2,64)
    set %sbot_ident $gettok($gettok($2,1,64),2,33)
    set %sbot_chan $4
    set %sbot_com $3
    set %sbot_other $5-
  }

  if ($3 isnum) { .signal -n sbot_r [ $+ [ $3 ] ] $4- }
  elseif ($2 == ping) { .signal -n sbot_ping $3 | halt }
  else { .signal -n sbot_ [ $+ [ $3 ] ] }
  echo @sbot 04 $1-
}
 
on *:signal:sbot_privmsg:{
if (%sbot_nick == $me) {
    if (title isin $gettok(%sbot_other,1,32)) {
      set %sbot_web_title 1
      sbot_web_open
    }
  }
}
 
alias sbot_web_open { sockopen sbot_web $gettok(%sbot_other,2,32) 80 }
 
on ^1:sockopen:sbot_web: { 
  .sockwrite -n $sockname GET / HTTP/1.1 | haltdef
  .sockwrite -n $sockname Host: $gettok(%sbot_other,2,32)
  .sockwrite $sockname $crlf  
} 
 
on 1:sockread:sbot_web: {
  sockread -f %sb_raw
  ;echo @sbot 04 %sb_raw
  if (%sbot_web_title) {
    if (&lt;title&gt; isin %sb_raw) { 
      set %sbot_web_ts $regex(%sb_raw,.*&lt;title&gt;(.*)&lt;/title&gt;.*)
      set %sbot_web_ts $regml(1)
      sbot_com privmsg %sbot_chan : $+ %sbot_nick $+ : [title: $gettok(%sbot_other,2,32) $+ $chr(93) $iif(%sbot_web_ts != $null, %sbot_web_ts, error: cannot locate title)
      .sockclose sbot_web
      unset %sbot_web_title | unset %sbot_web_ts
    }
  } 
}


It worked before but now it isnt.


Link Copied to Clipboard