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 

Using ? in HTTP grab sockets

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


Joined: 23 Jul 2006
Posts: 40

PostPosted: Fri Apr 06, 2007 8:21 pm    Post subject: Using ? in HTTP grab sockets Reply with quote

Alright, I'm trying to access a server using this code:

Code:
proc battle:flistenersdata { } {
global shoutcast shoutport shoutpass url_ xml_ fd_ state_
   set url_ "/radiosite/modules.php?name=Nuke-Cast"
   set xml_ ""

   # Setting up timeout length
   after 3000 set state_ timeout

   set fd_ [socket -async CENSORED CENSORED]
   fconfigure $fd_ -buffering line -buffersize 1024
   fileevent $fd_ writable {
      puts $fd_ "GET $url_ HTTP/1.0\nUser-Agent: CENSORED (Mozilla Compatible)\n"
      while { ![eof $fd_] } {
         gets $fd_ line
         append xml_ $line
      }
      set state_ connected
   }

   vwait state_
   close $fd_
   after cancel set state_ timeout

   return $xml_
}


However, I can only access this: /radiosite/modules.php. The ? in the url breaks the http grab. Do you have any ideas on fixing this? I have already tried a \.
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sat Apr 07, 2007 7:26 pm    Post subject: Reply with quote

I use ? in the weather script and it works.. Maybe the site you're trying to access is using POST method, not GET?

Here's an example of using POST from one of mc8's scripts (mcbanchan)

puts $sid "POST /report_bug.tcl HTTP/1.0\
\nHost: mc.purehype.net:80\
\nContent-type: application/x-www-form-urlencoded\
\nContent-Length: [expr [string length $query] +2]"
puts $sid \n$query


Here's an example from the weather script (using GET):

set webpage "/cgi-bin/findweather/getForecast?query=$location"
puts $wzsock "GET $webpage"


Why use the socket code anyway, when the http package gives you much more facility?
Back to top
View user's profile Send private message
Nara
Halfop


Joined: 23 Jul 2006
Posts: 40

PostPosted: Sun Apr 08, 2007 10:58 am    Post subject: Reply with quote

I honestly have no knowledge of how the http package works or where to obtain it, hence my use of sockets.
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sun Apr 08, 2007 6:27 pm    Post subject: Reply with quote

The http package is part of the newer versions of tcl, so you should already have it, and its manpage http.html. There's tons of example scripts in the archives and in the forums about how to use the http package, I've written a lot of scripts using it so look around.
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