0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ipwhoisを使ってwhoisで得られる情報を得る

Last updated at Posted at 2021-08-22
ykishi@dezembro X-Forwarded-For % cat whois_test.py 
#!/usr/bin/env python3

from ipwhois import IPWhois
import json
import sys


def get_info(ip):

  obj = IPWhois(ip)
  whoisInfo = obj.lookup_whois()

  # print(type(whoisInfo))

  name = whoisInfo["nets"][0]["name"]
  country = whoisInfo["nets"][0]["country"]

  return name, country


if __name__ == "__main__":

  result = get_info("51.103.36.90")
  print(type(result))
  print(result)
  print(",".join(result))
  print(result[0])
  print(result[1])
ykishi@dezembro X-Forwarded-For % ./whois_test.py 
<class 'tuple'>
('MICROSOFT', 'GB')
MICROSOFT,GB
MICROSOFT
GB
ykishi@dezembro X-Forwarded-For % 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?