| View previous topic :: View next topic |
| Author |
Message |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Sun Oct 17, 2010 3:33 pm Post subject: php text grabbing tcl |
|
|
let's say we have a www.example.com/test.php file on a website including the following, that randomly shows texts
| Code: | <html>
<head>
<title>mew mew mew moo</title>
</head>
<body>
<p style="background-color: #eeeeff; border: thin dashed; font-family: monospace; font-size: 115%; margin-left: 25%; padding: 1em; text-align: justify; width: 50%;">
Yo! First off I love the Lord Jesus. My name is Ron. I am a Freshman at
Winona State. My family is really important to me. I'm not doing this to
find a g/f. I just thought it would be funny and I like to meet new people.
Peace out!
</p>
<p style="font-size: 70%; text-align: right;">
45ms
</p>
</body>
</html>
|
any help around to grab this using a !trigger?:
| Code: | Yo! First off I love the Lord Jesus. My name is Ron. I am a Freshman at
Winona State. My family is really important to me. I'm not doing this to
find a g/f. I just thought it would be funny and I like to meet new people.
Peace out! |
_________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Last edited by spithash on Mon Jan 31, 2011 6:59 pm; edited 2 times in total |
|
| Back to top |
|
 |
username Op

Joined: 06 Oct 2005 Posts: 196 Location: Russian Federation, Podolsk
|
Posted: Sun Oct 17, 2010 3:58 pm Post subject: |
|
|
Try this: | Code: | bind pub - !trigger parce
proc parce {nick uhost hand chan text} {
::http::config -urlencoding utf-8 -useragent "Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.8.1) Gecko/2006101023 Firefox/2.0"
set url [::http::geturl "http://www.example.com/test.php" -timeout 15000]
set data [::http::data $url]
::http::cleanup $url
regsub -all -- {\n} $data "" data;
regexp -nocase -- {<p .*?>(.*?)</p>} $data -> info
putserv "PRIVMSG $chan :$info"
}
|
_________________ Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/ |
|
| Back to top |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Sun Oct 17, 2010 4:20 pm Post subject: |
|
|
yo @username
it works awesomely, thing is (i just noticed, sorry) that some words randomly are bolded in a few quotes like this:
| Code: | <html>
<head>
<title>mew mew mew moo</title>
</head>
<body>
<p style="background-color: #eeeeff; border: thin dashed; font-family: monospace; font-size: 115%; margin-left: 25%; padding: 1em; text-align: justify; width: 50%;">
yo think if i got a real doll and had a voodoo priest do<strong style="color: #a00;"> [censored] </strong>to it, and
attached lindsay lohan's soul to it, that if poke it she'd feel it and <strong style="color: #a00;">
[censored]?</strong>
</p>
<p style="font-size: 70%; text-align: right;">
1ms
</p>
</body>
</html>
|
so it fetches the bolding.coloring code aswell
considering [censored] are the bolded/colored words... _________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Sun Oct 17, 2010 4:41 pm Post subject: |
|
|
[censored] can be any word.. it was just filtered by egghelp's forum bad word filter  _________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun Oct 17, 2010 8:18 pm Post subject: |
|
|
| Code: | | regexp -nocase -- {<p .*?>(.*?)</p>} $data -> info |
Change this part above, to the part below..
| Code: | | regsub -all {<strong.*?>|</strong>} [regexp -nocase -- {<p .*?>(.*?)</p>} $data] "" info |
If instead, you'd like to leave these words in bold. Change it to look like it is below this:
| Code: | | regsub -all {<strong.*?>|</strong>} [regexp -nocase -- {<p .*?>(.*?)</p>} $data] "\002" info |
_________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Mon Oct 18, 2010 12:16 am Post subject: |
|
|
speechles, I got this:
| Quote: | [00:14:29] <@spithash> !test
[00:14:31] <@nagger> 1
|
after adding this
| Code: | | regsub -all {<strong.*?>|</strong>} [regexp -nocase -- {<p .*?>(.*?)</p>} $data] "\002" info |
_________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Mon Oct 18, 2010 1:28 pm Post subject: |
|
|
also I got another problem,
when the text is too long, it just cuts it off, it doesn't continue on a new line.. it just cuts it off  _________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
username Op

Joined: 06 Oct 2005 Posts: 196 Location: Russian Federation, Podolsk
|
Posted: Mon Oct 18, 2010 2:28 pm Post subject: |
|
|
Use this:
| Code: | bind pub - !trigger parce
proc parce {nick uhost hand chan text} {
::http::config -urlencoding utf-8 -useragent "Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.8.1) Gecko/2006101023 Firefox/2.0"
set url [::http::geturl "http://www.example.com/test.php" -timeout 15000]
set data [::http::data $url]
::http::cleanup $url
regsub -all -- {\n} $data "" data;
regexp -nocase -- {<p .*?>(.*?)</p>} $data -> info
regsub -all -- {<strong.*?>|</strong>} $info "\002" info;
while { $info != "" } {
putserv "PRIVMSG $chan :[string range $info 0 399]"
set info [string range $info 400 end]
}
} |
_________________ Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/ |
|
| Back to top |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Mon Oct 18, 2010 3:07 pm Post subject: |
|
|
...and it works awesomely!
I really thank you a LOT  _________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Mon Oct 18, 2010 4:28 pm Post subject: |
|
|
I just realized that it bolds EVERYTHING AFTER the bolded word on the website and the bolded word won't even appear...
The website I'm trying to fetch quotes from, is this:
http://rolloffle.churchburning.org/troll_me.php
not all quotes are word-bolded. if you refresh you will understand _________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Mon Oct 18, 2010 4:33 pm Post subject: |
|
|
The code looks like this:
| Code: | setudef flag troll
bind pub - !troll parce
proc parce {nick uhost hand chan text} {
if {[channel get $chan troll]} {
::http::config -urlencoding utf-8 -useragent "Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.8.1) Gecko/2006101023 Firefox/2.0"
set url [::http::geturl "http://rolloffle.churchburning.org/troll_me.php" -timeout 15000]
set data [::http::data $url]
::http::cleanup $url
regsub -all -- {\n} $data "" data;
regexp -nocase -- {<p .*?>(.*?)</p>} $data -> info
regsub -all -- {<strong.*?>|</strong>} $info "\002" info;
while { $info != "" } {
puthelp "PRIVMSG $chan :[string range $info 0 399]"
set info [string range $info 400 end]
}
}
} |
_________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Mon Oct 18, 2010 5:51 pm Post subject: |
|
|
uhm,
for some reason the bot gives me this error and ping timeouts...
| Quote: | Warning: over maximum server queue!
|
or
| Quote: | Warning: over maximum help queue!
|
depending on what i use.. puthelp or putserv.
I read old posts about it but I couldnt find anything that might help me avoid this... _________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Tue Oct 19, 2010 11:55 am Post subject: |
|
|
| Code: | [11:52:55] <spithash> .tcl queuesize
[11:52:55] <nagger> Tcl: 0
|
I get this after I use this script
| Code: | | Warning: over maximum help queue! |
anyone to enlightment me ? _________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Tue Oct 19, 2010 2:31 pm Post subject: |
|
|
ok so, this worked:
| Code: | | regsub -all -- {(<strong[^>]*>)|(</strong>)} $info "\002" info; |
 _________________ Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl |
|
| Back to top |
|
 |
adi2247 Voice
Joined: 30 Nov 2010 Posts: 10
|
Posted: Tue Nov 30, 2010 1:20 am Post subject: |
|
|
| This script is fantastic! how can i make it check the site and post to chat every X min between the hours of X and Y? |
|
| Back to top |
|
 |
|