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 

Get location info from www.example.com
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
popolare
Voice


Joined: 25 Mar 2007
Posts: 6

PostPosted: Sun Mar 25, 2007 3:44 pm    Post subject: Get location info from www.example.com Reply with quote

Hello,

i'm not hard with regular expressions (regexp) so I would be really happy if someone can help me with this:

Code:

proc ipaddress {nick uhost hand chan text} {
   set text [split [string trim $text]]
   if {$text == ""} {puthelp "PRIVMSG $chan :Please supply an IP number or hostname address.";return}
   set ipaddressquery [::http::formatQuery iq "$text"]
   set ipaddressurl "http://www.example.com"
   set page ""
   catch {set page [::http::geturl $ipaddressurl -query $ipaddressquery -timeout $::ipltout]} error

   set html [::http::data $page]
   ::http::cleanup $page
   set city "";

   regexp {.*? IP Address city:.*?size="2">(.*?) .*?} $html match city
   puthelp "PRIVMSG $chan :ipaddress results for '$text': $city"
   return
}


where $text is an IP
the proc is works but return empty $city..
Sure the regexp i'm using is wrong..
It would be cool to get most info of ip for country, city and isp

If anyone can help it would be amazing..
Thanks in advance.

Popolare


EDIT by user: this looks like spam - the site mentioned is not a ip location service. (i changed all the urls to example.com)
Back to top
View user's profile Send private message
JAFO
Voice


Joined: 13 Oct 2005
Posts: 19

PostPosted: Sun Mar 25, 2007 4:35 pm    Post subject: Reply with quote

i aint good at scripting , but perhaps ya can work from this script.
Back to top
View user's profile Send private message
popolare
Voice


Joined: 25 Mar 2007
Posts: 6

PostPosted: Sun Mar 25, 2007 6:25 pm    Post subject: Reply with quote

JAFO wrote:
i aint good at scripting , but perhaps ya can work from this script.


I'm already using this script but it doesn't have results from example.com

So i need right regexp to catch results from example.com
If someone can look please share your suggestions.

P.S.: JAFO, thanks anyway for script, i'm sure it will be usefull to many users if someone help us to add results from example.com (they have very fresh database with more than 93% accuracy!) to this script..

Thanks to everyone who will contribuite!
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sun Mar 25, 2007 8:02 pm    Post subject: Reply with quote

Nobody can help you unless you state what website needs to be accessed instead of "example.com."
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Sun Mar 25, 2007 8:06 pm    Post subject: Reply with quote

You might be interested in ipcheck.tcl.
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
rosc2112
Revered One


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

PostPosted: Mon Mar 26, 2007 5:43 am    Post subject: Reply with quote

Also http://members.dandy.net/~fbn/iplocator.tcl.txt
Uses antonline, geobytes and DNS-Stuff's ip geolocation pages.
Back to top
View user's profile Send private message
rosc2112
Revered One


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

PostPosted: Mon Mar 26, 2007 5:52 am    Post subject: Reply with quote

Actually, now that I looked at the code poopalare posted, that IS my script, butchered and minus credit.
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Mon Mar 26, 2007 8:23 pm    Post subject: Reply with quote

popolare wrote:
I'm already using this script but it doesn't have results from example.com

Apparently the user doesn't like it rosc2112. Laughing
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
popolare
Voice


Joined: 25 Mar 2007
Posts: 6

PostPosted: Tue Mar 27, 2007 8:24 am    Post subject: Reply with quote

rosc2112 wrote:
Actually, now that I looked at the code poopalare posted, that IS my script, butchered and minus credit.


Hello rosc2112,

it's just extract from your script.
It works fine with antonline, geoip, dnsstuff.

What I need is to make it work with ip-address .com (this is not spam, even if the aren't geolocation service they have very fresh and precise database)

Anyone still can help me?

They are using POST method of form (but geoip uses it too in your iplocator.tcl) just regexp must be adapted...
Back to top
View user's profile Send private message
rosc2112
Revered One


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

PostPosted: Tue Mar 27, 2007 9:01 pm    Post subject: Reply with quote

I don't see any ip lookup on that site, it just looks like a parked website.. Give me the url for the actual up lookup and I'll add it to the script.
Back to top
View user's profile Send private message
popolare
Voice


Joined: 25 Mar 2007
Posts: 6

PostPosted: Tue Mar 27, 2007 10:57 pm    Post subject: Reply with quote

rosc2112 wrote:
I don't see any ip lookup on that site, it just looks like a parked website.. Give me the url for the actual up lookup and I'll add it to the script.


Sorry, i spelled url incorrectly.
The correct url is http://www.ip-adress.com and the form is in homepage.

Thank you very much.

P.S.: Your script iplocator.tcl works like a charm!
Back to top
View user's profile Send private message
rosc2112
Revered One


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

PostPosted: Wed Mar 28, 2007 5:02 am    Post subject: Reply with quote

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:

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..)
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Mar 28, 2007 8:32 am    Post subject: Reply with quote

What if you make your script first load the form? (in case they use some server-side session tracking)
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
rosc2112
Revered One


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

PostPosted: Wed Mar 28, 2007 3:24 pm    Post subject: Reply with quote

I'm not sure I know how to do that, can you explain?

I had tried loading the page twice basically, once as a normal geturl, then as a query, but same result, it gives me my own address info, not the query's.

The other idea I had would be to use the socket code which would keep the connection open for get'ing the page, then sending the query.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Mar 28, 2007 4:01 pm    Post subject: Reply with quote

Making a webservice depend on keepalive does'nt sound like a viable solution, but then again I'm not developing that ip-adress service.

As for the queries submitted, did some digging with ethereal, and the urlencoded data looked like this (for bogus ip 123.456.789.0)
Code:
iq=123.456.789.0&submit=lookup+any+ip
with a content-type of "application/x-www-form-urlencoded". Nothing else fancy in the headers (tested using Firefox).

My suggestion was which you've already tried. Sorry I missed your note on not being state persistent either.
_________________
NML_375, idling at #eggdrop@IrcNET
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
Goto page 1, 2  Next
Page 1 of 2

 
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