Link to home
Start Free TrialLog in
Avatar of pcalabria
pcalabriaFlag for United States of America

asked on

Need help analyzing IP addresses in Access

My website tracks the IP of visitors who perform searches.

Does anyone know of a way to extract information from this IP using Microsoft Access o365?

For example, I suspect I can extract a country or perhaps location.  I'm not sure whether any other information can be extracted to determine the details of the website visitor.

Ideally, when they follow up with an email I would be able to match up the email to the website visit.

Impossible?  If yes, location info would help.

(Yes, I know they can be using a proxy server.  If they want to hide that's fine with me)
Avatar of strivoli
strivoli
Flag of Italy image

Depending on how the logs are generated you could use Logparser. For sure it works with IIS Logs.
https://www.microsoft.com/en-us/download/details.aspx?id=24659

Avatar of pcalabria

ASKER

strivoli...
I checked the link but did not understand... let me be sure my question is clear...
We have a website that is hosted on a shared computer.. ie GoDaddy
When someone performs a website search I track the search and IP using a script. The IP is stored in an SQL table.
When I view the table contents I can tell the IP of the visitor, and the searches performed, but do not know any other information.

I would like to know more about the visitor than just the IP..
At this point, I am only familiar with the ASP Server Variables collection.

Can you.. or anyone.. help?
Uhm... I think Logparser won't help since it mostly fits on Text Logs.
<<https://officetricks.com/find-ip-address-location-geoip-lookup/ >>

 The issue is not the code for doing it, but rather someone that is going to be willing for you to hit their WHOIS lookup repeatedly.

 Most free services have a throttling limit, so if you want consistent service, you are going to need to pay for it.

Take a look at:

https://blog.api.rakuten.net/top-domain-whois-api/

 To get an idea of what I'm talking about.

Jim.
I did a quick test...the geoip now is https://ipstack.com
and it needs an API Key
as for the restrictions mentioned by Jim you could check what is allowed....i see its 

10.000 requests / mo for the free plan

ipstack.com looks awesome.
How would I integrate that with my Access routine?
All I have now is an IP in a table.

Thanks!
You should be able to simply replace the http code in the code sample and it should work...i tried to make a sample but i forgot i am behind a proxy and the response was lost.
The http GET should be something like
https://api.ipstack.com/The_IP? access_key = YOUR_ACCESS_KEY

Open in new window


There are plenty of API's for this, others include https://ipwhois.io/documentation,https://pypi.org/project/ipwhois/,https://api.iplocation.net/

To run through your list of IP's in a table, you are going to do an  httppost

Using https://api.iplocation.net/?ip=XX.XX.XX.XX as an example.  Below is what I use in vbs and I think vba will be similar if not the same.


ip = request("IP")


URL = "https://api.iplocation.net/"


  DataToSend = "ip=" & ip
    dim xmlhttp
    set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
    xmlhttp.Open "GET",URL,false
    xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    xmlhttp.send DataToSend

    Response.ContentType = "text"
    'Response.Write xmlhttp.responseText

    returned_data = xmlhttp.responseText

    Set xmlhttp = nothing

Open in new window


ASKER CERTIFIED SOLUTION
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks all!

Scott, I checked the links you provided (first two did not work) and it seems ipwhois may be a great free source for the country, and while other location info is available, it may require a premium membership

John, awesome solution!  IPstack seems to provide a free account with lots of information in addition to country.  I tested the sample program you provided and it's a great solution, thank you.  

I am stuck on the JSON parser...I couldn't figure out how to get it into my Access app.  There is an install feature, which seemed strange to me.  I would expect to be able to copy the code into a module but could not get it to work.

I need to extract the information returned to add to my db..using this converter should prove more efficient than string manipulations.

Thank you

Just import the module for JSON
https://ipwhois.io/documentation

https://pypi.org/project/ipwhois/

That was odd. There were extra characters in the link you just needed to remove.
Thanks Scott.
Like I mentioned before, I was able to get John's code working, which also provided long, lat, city, region, and zip in the free version... but thanks a lot.  I appreciated your help.