Ok, I tried this for hours, trying to figure out why it's only returning MY address, despite what the query is asking for, but it seems like the only way the form works is if you actually submit it from the webpage, which doesn't make sense to me, because the query string used by the bot is exactly the same..
Code: Select all
proc ipadrlocate {nick chan text} {
set ipadrurl "http://www.ip-adress.com/"
set page "";set ipcountry "";set ipstate "";set ipcity "";set iplat ""
set iplong "";set ipisp "";set iporg ""
set ipspeed "";set ipadrtemp "";set html ""
set ipadrquery [::http::formatQuery iq "[join $text]" submit "lookup any ip"]
catch {set page [::http::geturl $ipadrurl -timeout $::ipltout -query $ipadrquery]} error
putcmdlog "text '$text' query '$ipadrquery'"
if {[string match -nocase "*couldn't open socket*" $error]} {
puthelp "PRIVMSG $chan :Error: Couldn't connect to IP-Adress.com..Try again later"
::http::cleanup $page
return
}
if {[::http::status $page] == "timeout"} {
puthelp "PRIVMSG $chan :Error: Connection to IP-Adress.com timed out."
::http::cleanup $page
return
}
set html [::http::data $page]
::http::cleanup $page
# this regexp is word-wrapped
if {[regexp {>My ip address:</font>.*?<font.*?>(.*?)</font>.*?>IP
country:</font>.*?<img src="/flags/.*?png">(.*?)</font>.*?>IP.*?Address
state:</font>.*?<font.*?>(.*?)</font>.*?>IP.*?Address
city:</font>.*?<font.*?>(.*?)</font>.*?>IP
latitude:</font>.*?<font.*?>(.*?)</font>.*?>IP
longitude:</font>.*?<font.*?>(.*?)</font>.*?>isp:</font>.*?<font.*?>(.*?)</font>.*?>organization:</font>.*?<font.*?>(.*?)</font>.*?>your
speed:</font>.*?<font.*?>(.*?)</font>} $html match ipcountry ipstate ipcity
iplat iplong ipisp iporg ipspeed]} {
# other formatting junk deleted for brevity
}
The other procs I use for the binds and for resolving hostnames to ip's has been omitted for brevity.
If anyone can shed some light as to why the form on ip-adress.com won't accept the query from the bot, that would be appreciated.
Otherwise, the script would be working, I have everything else working, the regexp works, and I have the output formatted and all, I just can't figure out why every query is returning my address info (the default when you 1st load the page.)
I've run a bunch of tests from lynx, but the result is the same. It's like ip-adress.com won't accept any query unless it's sent directly from the page's submit button.. It's not cookies or java, cos I have that disabled in lynx.. There's no persistent state either, so it's not that. I did a trace log from lynx to check the actual query string being sent and I have that right too, afaict.. As far as I can tell, the above should work but... I thought it might've been the urlencoding, so I changed that as well, made no diff.
The only vague guess I have: the problem may be when the formatQuery turns the dots in the ip into %2e which is what it's supposed to do, and presumably it's what all browsers do when a query is sent. If that is indeed the problem, I see no way around it, as formatQuery doesn't provide any way of sending literal chars, that I know of.
BTW, I don't think ip-adress.com's db is all that special, compared to the other 3 I already use in the script. It places my IP far from where I am actually located, where the other 3 place it much closer (anti-online places it at the nearest CO; the other 2 get the NOC; ip-adress, I have no idea where it's getting it's data..)