當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。