|
Joined: Feb 2003
Posts: 143
Vogon poet
|
OP
Vogon poet
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><!
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
Hoopy frood
Joined: May 2003
Posts: 2,265 |
//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><!)
new username: tidy_trax
|
|
|
|
Joined: Dec 2002
Posts: 2,809
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,809 |
.echo -q $regex(%thetext,.*(<title>.*</title>).*) .echo -a The title is: $regml(1)
|
|
|
|
Joined: May 2003
Posts: 2,265
Hoopy frood
|
Hoopy frood
Joined: May 2003
Posts: 2,265 |
new username: tidy_trax
|
|
|
|
Joined: Feb 2003
Posts: 143
Vogon poet
|
OP
Vogon poet
Joined: Feb 2003
Posts: 143 |
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 (<title> isin %sb_raw) {
set %sbot_web_ts $regex(%sb_raw,.*(<title>.*</title>).*)
set %sbot_web_ts $remove($regml(1),<title>,</title>)
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.comI get this - * /sockwrite: 'sbot_web' not connected (line 92, sbot.txt) - is there a way to fix this?
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
.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.
-KingTomato
|
|
|
|
Joined: Feb 2003
Posts: 143
Vogon poet
|
OP
Vogon poet
Joined: Feb 2003
Posts: 143 |
is there a way to make that not show up then? I used .sockwrite but it still shows.
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
paste ur script again highlighting the cline you have a problem with pls
-KingTomato
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
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.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Feb 2003
Posts: 143
Vogon poet
|
OP
Vogon poet
Joined: Feb 2003
Posts: 143 |
nm, I tried to see if I could use ^ and it worked. Thanks though.
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
}
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Dec 2002
Posts: 2,809
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,809 |
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.
|
|
|
|
Joined: Feb 2003
Posts: 143
Vogon poet
|
OP
Vogon poet
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
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Feb 2003
Posts: 143
Vogon poet
|
OP
Vogon poet
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.
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 (<title> isin %sb_raw) {
set %sbot_web_ts $regex(%sb_raw,.*<title>(.*)</title>.*)
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.
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
|