5/2/2024 0 Comments Geobytes ip address locatoradd_option( '-latitude', help = 'print the latitude', action = 'store_const', const = '%(latitude)f', dest = 'format')īasic_group. add_option( '-iso3', help = 'print the 3-letter ISO country code', action = 'store_const', const = '%(iso3)s', dest = 'format')īasic_group. add_option( '-iso2', help = 'print the 2-letter ISO country code', action = 'store_const', const = '%(iso2)s', dest = 'format')īasic_group. add_option( '-internet', help = 'print the internet country code', action = 'store_const', const = '%(internet)s', dest = 'format')īasic_group. add_option( '-icbm', help = 'print the latitude and longitude equivalent to -format="%(latitude)f, %(longitude)f"', action = 'store_const', const = "%(latitude), %(longitude)", dest = 'format')īasic_group. add_option( '-country', help = 'print the country', action = 'store_const', const = '%(country)s', dest = 'format')īasic_group. add_option( '-city', help = 'print the city name', action = 'store_const', const = '%(city)s', dest = 'format')īasic_group. add_option( '-certainty', help = 'print \'s certainty about the location', action = 'store_const', const = '%(certainty)d', dest = 'format')īasic_group. add_option( '-unsafe', help = 'use eval() as an ad-hoc json decoder (use at your own risk)', action = 'store_true', dest = 'unsafe')īasic_group. add_option( '-help-format', help = 'describe valid format strings', action = 'callback', callback = formathelp) set_defaults( format = """%(latitude)f, %(longitude)f""", unsafe = False) OptionGroup( parser, "Custom output options") OptionGroup( parser, "Basic output options")Ĭustom_group = optparse. If no IP addresses are specified, read IP addresses, one per line, from standard input.""")īasic_group = optparse. If no format is specified, print latitude and longitude. Options are mutually exclusive only the last one specified will take effect. OptionParser( usage = """usage: %prog IP Locationcode longitude region regionid timezoneĪs an example, -format="%%(latitude)f, %%(longitude)f" is equivalent to -icbm""" Where c is a conversion type (a la python or printf) andĬertainty city cityid code country countryidįips internet ipaddress iso2 iso3 ison latitude Print """Format strings may include variables of the form %(varname)c, Raise RuntimeError( "GeoBytes error: Results don't match request - got results for %s" % json_dict)ĭef formathelp( opt, ostr, v, p, * a, ** kwa): \nUse the -unsafe option to use python eval() as an ad-hoc json decoder") Raise RuntimeError( "Neither the json or simplejson module is available. # this is public domain, there is no warranty, share and enjoyįrom simplejson import loads as jsonparse # of-charge geobytes API only allows 20 requests per hour. # requires python 2.6 or json library note that the free. # geographic location for a particular IP address # geo-ip.py uses the API to find the probable
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |