| View previous topic :: View next topic |
| Author |
Message |
Scott Voice

Joined: 24 Jul 2004 Posts: 11
|
Posted: Fri Sep 23, 2005 11:30 am Post subject: Query String |
|
|
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 |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Sep 23, 2005 12:18 pm Post subject: |
|
|
| 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 |
|
 |
Scott Voice

Joined: 24 Jul 2004 Posts: 11
|
Posted: Fri Sep 23, 2005 12:57 pm Post subject: |
|
|
Hi and thanks for that....
I'll try and place that in my code, might be back if it dont work
Edit: It didnt work 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 |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Fri Sep 23, 2005 3:44 pm Post subject: |
|
|
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 |
|
 |
Scott Voice

Joined: 24 Jul 2004 Posts: 11
|
Posted: Fri Sep 23, 2005 4:04 pm Post subject: |
|
|
Ahh right, thanks for the input
Will have another go! |
|
| Back to top |
|
 |
|