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.

Query String

Old posts that have not been replied to for several years.
Locked
User avatar
Scott
Voice
Posts: 11
Joined: Sat Jul 24, 2004 7:58 am

Query String

Post by Scott »

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/? ... ARCHPHRASE[/b]&Category=-1&searchFP=p

How would i be able to do that in tcl?
User avatar
Sir_Fz
Revered One
Posts: 3793
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

set searchphrase "searchphrase"

set searchurl "http://www.WEBSITE.com/search/query/p/?q=${searchphrase}&Category=-1&searchFP=p"
User avatar
Scott
Voice
Posts: 11
Joined: Sat Jul 24, 2004 7:58 am

Post by Scott »

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: Select all


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
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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: Select all

 tag when posting logs, code
User avatar
Scott
Voice
Posts: 11
Joined: Sat Jul 24, 2004 7:58 am

Post by Scott »

Ahh right, thanks for the input :)

Will have another go!
Locked