This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

egghttp horoscope

Old posts that have not been replied to for several years.
User avatar
hikaro
Halfop
Posts: 68
Joined: Wed Mar 10, 2004 4:29 am

egghttp horoscope

Post by hikaro »

Hai i'm trying to make horoscope tcl but it seems doesnt work, if you have more time can you recheck my script please...

Code: Select all

bind pub - !aries bosen:aries

set url "http://www.detikhot.com/index.php/detik.horoskop/idkanal/113/p/horoskopmasehi/d/aries"

proc bosen:aries {sock} {
  global url
  set headers [egghttp:headers $sock]
  set body [egghttp:data $sock]

  regsub -all "\n" $body "" body
  regsub -all -nocase {<br>} $body "<br>\n" body

  regexp {<b>Aries</b> <br> (.*)<br>} $body - peruntungan

  putlog "Peruntungan: $peruntungan"
}

proc our:dcctrigger {hand idx text} {
  global url 
  set sock [egghttp:geturl $url bosen:aries]
  return 1
}  
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

The stuff you want from that page is betwen two lines "<blockquote>" and "</blockquote>" .. Remove all the garbage with "regsub -all -- {<[^>]+>|<} $garbage "" clean" and the 3-rd line is your stuff. Anyway, here is something using the default http package.

Code: Select all

if {[catch {package require http} err]} {
  putlog "\002horoscope.tcl\002 requires http package in order to work. Unload the script if you don't have the http package."
  return
}

set horoscope(url) "http://www.detikhot.com/index.php/detik.horoskop/idkanal/113/p/horoskopmasehi/d/aries" 

bind pub - !aries bosen:aries 

proc bosen:aries {nick uhost hand chan text} { 
  global horoscope
  set token [::http::geturl $horoscope(url)]
  set content [::http::data $token]
  ::http::cleanup $content
  set top "<blockquote>"
  set bottom "</blockquote>"
  set tosave [string range $content [set f [string first $top $content]] [string first $bottom $content $f]] 
  regsub -all -- {<[^>]+>|<} $tosave "" tosave 
  set l 3 ; set i 0
  foreach line [split $tosave \n] {
    if {$i == $l} {
      set msg $line
      break
    }
    incr i
  }
  # use the $msg variable to do whatever you want
}
Last edited by caesar on Sun Jan 02, 2005 1:39 pm, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
User avatar
hikaro
Halfop
Posts: 68
Joined: Wed Mar 10, 2004 4:29 am

Post by hikaro »

caesar, thanks for your reply but it doesnt work. i typed !aries and it didnt come anything... i dont see any error log in dcc chat also.

any idea?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

caesar wrote: # use the $msg variable to do whatever you want
Have you used this variable as I've said?
Once the game is over, the king and the pawn go back in the same box.
User avatar
hikaro
Halfop
Posts: 68
Joined: Wed Mar 10, 2004 4:29 am

Post by hikaro »

yeah i did put it...
if {$i == $l} {
set msg $line
puthelp "privmsg $chan :$msg"
break

nothing come out and no error found also
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Because it's a big line the eggdrop dosen't seem to be able to tell it to the channel. I meant instead of the "# use the $msg variable to do whatever you want" add your stuff, anyway. Here is some sort of solution.. add something like:

Code: Select all

set f [open result.txt w]
puts $f $msg
close $f
and then see if it's something in that result.txt file or not and figure out a way to split that text in something the eggdrop can chew. :mrgreen: :P
Once the game is over, the king and the pawn go back in the same box.
User avatar
hikaro
Halfop
Posts: 68
Joined: Wed Mar 10, 2004 4:29 am

Post by hikaro »

yeahh i saw the text in result.txt but i don't know how to split it hehe
i want split it into 5 line (aries,peruntungan:,Karir:,Keuangan,cinta).

and i got 1 more question, this zodiac is update everyday if i do !aries in the next day will it replace the first one?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Yes, it will put in the result.txt file what he gets from that page, and learn to split yourself the result, I'm too lazy. :P
Once the game is over, the king and the pawn go back in the same box.
User avatar
hikaro
Halfop
Posts: 68
Joined: Wed Mar 10, 2004 4:29 am

Post by hikaro »

hehehe i dont know how to split it caesar, or can you give me the web that give tutorial for it? i will learn of it
thank you
User avatar
hikaro
Halfop
Posts: 68
Joined: Wed Mar 10, 2004 4:29 am

Post by hikaro »

hmm or perhaps the rest who has more time please help me... 8)
User avatar
hikaro
Halfop
Posts: 68
Joined: Wed Mar 10, 2004 4:29 am

Post by hikaro »

hello anyone pls help meee..
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

shut up already, you're becoming annoying
User avatar
hikaro
Halfop
Posts: 68
Joined: Wed Mar 10, 2004 4:29 am

Post by hikaro »

demond: sorry if i become anoying to you but i dont think others will think the same as you, this forum made for helping each other if you cant help me so please just ignore it!!!![/code][/b]
User avatar
KrzychuG
Master
Posts: 306
Joined: Sat Aug 16, 2003 2:51 pm
Location: Torun, Poland
Contact:

Post by KrzychuG »

Well, i think that others may think same as demond. Yes, this forum was mode for helping people, but for helping, not for doing whole job. Please use your brain, try to figure out how to get needed data.
Que?
User avatar
hikaro
Halfop
Posts: 68
Joined: Wed Mar 10, 2004 4:29 am

Post by hikaro »

ohh ok if you think so, so sorry to bother, if i know how to figure it out i wont ask here...
Locked