add geo location finder
This commit is contained in:
22
w.py
22
w.py
@@ -1,19 +1,35 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# TODO: aliast in bashrc
|
||||
# TODO pass argv to set time interval and maybe even the location ;D
|
||||
# TODO, fetch the ipgeolocation, and basically compare against databse from xml on vedur - fetch the data and make an array
|
||||
# FIXME, there is a bug with NULL/None values
|
||||
import requests, os, sys
|
||||
import requests, os, sys, re, json
|
||||
from xml.etree import ElementTree
|
||||
import urllib
|
||||
from datetime import date, datetime, time, timedelta
|
||||
from pprint import pprint
|
||||
import platform
|
||||
from urllib2 import urlopen
|
||||
|
||||
url = 'http://ipinfo.io/json'
|
||||
response = urlopen(url)
|
||||
data = json.load(response)
|
||||
|
||||
IP=data['ip']
|
||||
org=data['org']
|
||||
city = data['city']
|
||||
country=data['country']
|
||||
region=data['region']
|
||||
|
||||
print 'Your IP detail\n '
|
||||
print 'IP : {4} \nRegion : {1} \nCountry : {2} \nCity : {3} \nOrg : {0}'.format(org,region,country,city,IP)
|
||||
|
||||
|
||||
|
||||
|
||||
os.system('clear')
|
||||
|
||||
location = 1 # Reykjavik
|
||||
|
||||
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
justnow = datetime.strptime(now, "%Y-%m-%d %H:%M:%S")
|
||||
|
Reference in New Issue
Block a user