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 

Query String

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
Scott
Voice


Joined: 24 Jul 2004
Posts: 11

PostPosted: Fri Sep 23, 2005 11:30 am    Post subject: Query String Reply with quote

Hi All

Im trying to build a TCL script that will search a site for a file, however the default search has the search string in the middle of the query. So im trying to make it so i can split the search URL and add a word in the middle...

http://www.WEBSITE.com/search/query/p/?q=SEARCHPHRASE&Category=-1&searchFP=p

How would i be able to do that in tcl?
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Sep 23, 2005 12:18 pm    Post subject: Reply with quote

Code:
set searchphrase "searchphrase"

set searchurl "http://www.WEBSITE.com/search/query/p/?q=${searchphrase}&Category=-1&searchFP=p"

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Scott
Voice


Joined: 24 Jul 2004
Posts: 11

PostPosted: Fri Sep 23, 2005 12:57 pm    Post subject: Reply with quote

Hi and thanks for that....

I'll try and place that in my code, might be back if it dont work Sad

Edit: It didnt work Sad This is the code i have (edited from another tcl i found, author unknown)

Code:


proc pub:file { nick uhost handle channel arg } {
 global agent
   if {[llength $arg]==0} {
      putserv "PRIVMSG $channel :FFS! Use The Correct Syntax! !file FILENAME"
   } else {

      set searchphrase "searchphrase"

      set query "http://www.WEBSITE.com/search/query/p/?q=${searchphrase}&Category=-1&searchFP=p"
      set query "$query[lindex $arg 0]"
   #   putserv "PRIVMSG $channel :$query"
                set token [http::config -useragent $agent]
      set token [http::geturl $query]
      set html  [http::data $token]
      puts stderr ""
      upvar #0 $token state
      set max 0
   #   foreach {name value} $state(meta) {
   #      putserv "PRIVMSG $channel :$value"
   #   }
   #   putserv "PRIVMSG $channel :$html"
      set result "[lindex $html 1]"
      set result [string range $result [expr [string first = $result]+2] [expr [string first > $result]-2]]
      putserv "PRIVMSG $channel :$result"
   }
}



When i type, !File Dredd in the channel to test, i get the following error:

[12:59] Tcl error [pub:file]: list element in quotes followed by ">" instead of space
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Sep 23, 2005 3:44 pm    Post subject: Reply with quote

do not use [lindex] on a string directly, [split] that string first

and instead of patching into url-encoded string, use [::http::formatQuery]
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
Scott
Voice


Joined: 24 Jul 2004
Posts: 11

PostPosted: Fri Sep 23, 2005 4:04 pm    Post subject: Reply with quote

Ahh right, thanks for the input Smile

Will have another go!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive 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