egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

php text grabbing tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Sun Oct 17, 2010 3:33 pm    Post subject: php text grabbing tcl Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
username
Op


Joined: 06 Oct 2005
Posts: 196
Location: Russian Federation, Podolsk

PostPosted: Sun Oct 17, 2010 3:58 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Sun Oct 17, 2010 4:20 pm    Post subject: Reply with quote

yo @username Smile

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 Sad

considering [censored] are the bolded/colored words...
_________________
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Sun Oct 17, 2010 4:41 pm    Post subject: Reply with quote

[censored] can be any word.. it was just filtered by egghelp's forum bad word filter Razz
_________________
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sun Oct 17, 2010 8:18 pm    Post subject: Reply with quote

Code:
regexp -nocase -- {<p .*?>(.*?)</p>} $data -> info

Change this part above, to the part below.. Smile

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
View user's profile Send private message
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Mon Oct 18, 2010 12:16 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Mon Oct 18, 2010 1:28 pm    Post subject: Reply with quote

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 Confused
_________________
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
username
Op


Joined: 06 Oct 2005
Posts: 196
Location: Russian Federation, Podolsk

PostPosted: Mon Oct 18, 2010 2:28 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Mon Oct 18, 2010 3:07 pm    Post subject: Reply with quote

...and it works awesomely!

I really thank you a LOT Very Happy
_________________
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Mon Oct 18, 2010 4:28 pm    Post subject: Reply with quote

I just realized that it bolds EVERYTHING AFTER the bolded word on the website and the bolded word won't even appear... Confused

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
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Mon Oct 18, 2010 4:33 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Mon Oct 18, 2010 5:51 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Tue Oct 19, 2010 11:55 am    Post subject: Reply with quote

Code:
[11:52:55] <spithash> .tcl queuesize
[11:52:55] <nagger> Tcl: 0


I get this after I use this script Confused

Code:
Warning: over maximum help queue!


anyone to enlightment me ?
_________________
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
spithash
Master


Joined: 12 Jul 2007
Posts: 248
Location: Libera

PostPosted: Tue Oct 19, 2010 2:31 pm    Post subject: Reply with quote

ok so, this worked:

Code:
regsub -all -- {(<strong[^>]*>)|(</strong>)} $info "\002" info;


Smile
_________________
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
adi2247
Voice


Joined: 30 Nov 2010
Posts: 10

PostPosted: Tue Nov 30, 2010 1:20 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber