当前位置: 首页>>代码示例>>Python>>正文


Python geocoder.ip方法代码示例

本文整理汇总了Python中geocoder.ip方法的典型用法代码示例。如果您正苦于以下问题:Python geocoder.ip方法的具体用法?Python geocoder.ip怎么用?Python geocoder.ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在geocoder的用法示例。


在下文中一共展示了geocoder.ip方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: urltoip

# 需要导入模块: import geocoder [as 别名]
# 或者: from geocoder import ip [as 别名]
def urltoip(urltarget):

    geoloc= ''
    target = ''
    finalip = ''
    result = ''

    try:
        target = urlparse(urltarget)
        result = target.netloc
        finalip = socket.gethostbyname(result)
        if finalip is not None:
            geoloc = geocoder.ip(finalip)
            if (geoloc is not None):
                return geoloc.city
            else:
                result = ''
                return result 
        else:
            result = "Not Found"
            return result

    except:
        result = "Not Found"
        return result
        print(mycolors.reset) 
开发者ID:alexandreborges,项目名称:malwoverview,代码行数:28,代码来源:malwoverview.py

示例2: getLatLan

# 需要导入模块: import geocoder [as 别名]
# 或者: from geocoder import ip [as 别名]
def getLatLan():
    try:
        g = geocoder.ip('me')
        val = g.latlng 
        return val[0], val[1]
    except Exception as e:
        return None, None 
开发者ID:dark-archerx,项目名称:Traffic-Signs-and-Object-Detection,代码行数:9,代码来源:guir.py

示例3: getLatLan

# 需要导入模块: import geocoder [as 别名]
# 或者: from geocoder import ip [as 别名]
def getLatLan():
    try:
        g = geocoder.ip('me')
        val = g.latlng
        return val[0], val[1]
    except Exception as e:
        return None, None 
开发者ID:dark-archerx,项目名称:Traffic-Signs-and-Object-Detection,代码行数:9,代码来源:main.py

示例4: getCity

# 需要导入模块: import geocoder [as 别名]
# 或者: from geocoder import ip [as 别名]
def getCity():
    global city
    g = geocoder.ip('me')
    city = g.city 
开发者ID:dark-archerx,项目名称:Traffic-Signs-and-Object-Detection,代码行数:6,代码来源:main.py

示例5: ipGeo

# 需要导入模块: import geocoder [as 别名]
# 或者: from geocoder import ip [as 别名]
def ipGeo():
    os.system("clear")
    x = input("Enter IP Address:")
    g = geocoder.ip(x)
    print(g.latlng) 
开发者ID:omarrajab,项目名称:NoJlede,代码行数:7,代码来源:NoJlede.py

示例6: get_current_location

# 需要导入模块: import geocoder [as 别名]
# 或者: from geocoder import ip [as 别名]
def get_current_location():
    import geocoder

    g = geocoder.ip("me")
    return g.y, g.x 
开发者ID:Breakend,项目名称:experiment-impact-tracker,代码行数:7,代码来源:get_region_metrics.py

示例7: test_entry_points

# 需要导入模块: import geocoder [as 别名]
# 或者: from geocoder import ip [as 别名]
def test_entry_points():
    geocoder.ip
    geocoder.osm
    geocoder.w3w
    geocoder.bing
    geocoder.here
    geocoder.tgos
    geocoder.baidu
    geocoder.gaode
    geocoder.yahoo
    geocoder.mapbox
    geocoder.google
    geocoder.yandex
    geocoder.tomtom
    geocoder.arcgis
    geocoder.ipinfo
    geocoder.mapzen
    geocoder.geonames
    geocoder.mapquest
    geocoder.timezone
    geocoder.maxmind
    geocoder.elevation
    geocoder.freegeoip
    geocoder.geolytica
    geocoder.timezone
    geocoder.opencage
    geocoder.places
    geocoder.canadapost
    geocoder.tamu
    geocoder.geocodefarm
    geocoder.uscensus 
开发者ID:DenisCarriere,项目名称:geocoder,代码行数:33,代码来源:test_geocoder.py

示例8: co_list

# 需要导入模块: import geocoder [as 别名]
# 或者: from geocoder import ip [as 别名]
def co_list(chat_id, command, globrand):
    if (command == 'Where are you?'):
        import geocoder
        import urllib
        url = 'http://myexternalip.com/raw'
        bot.sendLocation(chat_id, geocoder.ip(urllib.urlopen(url).read()).latlng[0], geocoder.ip(urllib.urlopen(url).read()).latlng[1])
    mystring = command
    if (mystring.partition(" ")[0] == 'Say,'):
        vari = mystring.partition(" ")[2]
        if globrand <= 5:
            bot.sendMessage(chat_id, vari.rpartition('or')[0])
        else:
            bot.sendMessage(chat_id, vari.rpartition('or')[2])
    if (command == 'Where are you all?'):
        bot.sendMessage(chat_id, 'I am here!')
    if (command == 'Screenshot'):
        app = QApplication(sys.argv)
        QPixmap.grabWindow(QApplication.desktop().winId()).save('screenshot.jpg', 'jpg')
        bot.sendPhoto(chat_id, open('screenshot.jpg', 'rb'))
    if (command == 'RAM usage'):
        bot.sendMessage(chat_id, 'Nearly {}% of RAM is used.'.format(virtual_memory().percent))
    if (command == 'Who is your creator?'):
        bot.sendMessage(chat_id, 'His nick is E_KOsh...')
        bot.sendMessage(chat_id, "You might want to write him... Don't be so shy - @E_KOsh")
    if (command == 'CPU usage'):
        bot.sendMessage(chat_id, "About {}% of my CPU power is used.".format(cpu_percent()))
    if (command == 'What is the time?'):
        bot.sendMessage(chat_id, str(datetime.datetime.now()))
    if (command == 'Uptime'):
        u = round(uppp() / 3600, 1)
        bot.sendMessage(chat_id, 'I am already working for {} hours.'.format(u))

# Startup welcoming and a tick to DB with powerup state 
开发者ID:EKOsh,项目名称:TeleMonBot,代码行数:35,代码来源:Main.py

示例9: get_queryset

# 需要导入模块: import geocoder [as 别名]
# 或者: from geocoder import ip [as 别名]
def get_queryset(self):
        most_recent_moniker, most_recent = pgettext("value::plural", "MOST RECENT"), False
        if self.query in (most_recent_moniker, most_recent_moniker.replace(" ", "_")):
            most_recent = True
            self.query = ''

        qs = (
            self.queryset
            .select_related(None)
            .defer('description', 'family_members_visibility')
            .select_related('owner', 'owner__user')
            .defer('owner__description', 'owner__email_visibility')
        )

        self.result = geocode(self.query)
        if self.query and self.result.point:
            if any([self.result.country and not self.result.country_code, self.result.state, self.result.city]):
                return (qs
                        .annotate(distance=Distance('location', self.result.point))
                        .order_by('distance'))
            elif self.result.country:  # We assume it's a country
                self.paginate_first_by = 50
                self.paginate_orphans = 5
                self.country_search = True
                return (qs
                        .filter(country=self.result.country_code.upper())
                        .order_by('-owner__user__last_login', '-id'))
        position = geocoder.ip(self.request.META['HTTP_X_REAL_IP']
                               if settings.ENVIRONMENT != 'DEV'
                               else "188.166.58.162")
        position.point = Point(position.xy, srid=SRID) if position.xy else None
        logging.getLogger('PasportaServo.geo').debug(
            "User's position: %s, %s",
            position.address if position.ok and position.address else "UNKNOWN",
            position.xy if position.ok else position.error
        )
        if position.point and not most_recent:
            # Results are sorted by distance from user's current location, but probably
            # it is better not to creep users out by unexpectedly using their location.
            qs = qs.annotate(internal_distance=Distance('location', position.point)).order_by('internal_distance')
        else:
            qs = qs.order_by('-owner__user__last_login', '-id')
        return qs 
开发者ID:tejoesperanto,项目名称:pasportaservo,代码行数:45,代码来源:listing.py

示例10: add_device

# 需要导入模块: import geocoder [as 别名]
# 或者: from geocoder import ip [as 别名]
def add_device(access_token, room_name):

    get_device_info = api_endpoint + '/aaa/listUserSettings.json?'
    add_device_url = api_endpoint + '/aaa/addNewDevice.json?'
    mac = get_mac()
    macid = ':'.join(("%012X"%mac)[i:i+2] for i in range(0,12,2))

    param1 = {
        'access_token':access_token
    }

    # print(access_token)

    if access_token is not None:
        device_info_response = requests.get(get_device_info,param1)
        device_info = device_info_response.json()

    # print(device_info)

    if device_info is not None:
        device = device_info['devices'] # list of existing mac ids
        print(device)
        session = device_info['session'] # session info
        identity = session['identity']
        name = identity['name']
        curr_location = geocoder.ip('me')
        params2 = {
        'macid': macid,
        'name': name,
        'room': str(room_name),
        'latitude': curr_location.lat,
        'longitude': curr_location.lng,
        'access_token': access_token
        }

        for dev in device:
            if dev == macid:
                print('Device already configured')
                return
            else :
                adding_device = requests.post(add_device_url, params2)
                print(adding_device.url) 
开发者ID:fossasia,项目名称:susi_api_wrapper,代码行数:44,代码来源:main.py


注:本文中的geocoder.ip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。