Skip to main content

No project description provided

Project description

python whois parser command and library, that use template text parser(ttp).

Feture

  • Parsing is based on text templates, making it easy to add target domains.

  • Local language information is also subject to management.

But, currently under development, the status is as follows.

  • Time and time zone information may be in text format

  • May contain unnecessary data

Install

git clone https://github.com/blacknon/pywhois2
cd pywhois2
pip install ./

Usage

Command

$ whois2 myna.go.jp | jq
{
  "updated": "2023/02/01 01:11:56 +0900",
  "created": "2022/01/06 00:00:00 +0900",
  "tech_name": "KA35357JP",
  "registrant_name": "KA35357JP",
  "registrant_organization_type": "Government",
  "registrant_organization_type_local": "政府機関",
  "registrant_organization": "Accounting Division,Digital Agency",
  "registrant_organization_local": "デジタル庁 戦略・組織グループ会計担当",
  "registrant_organization_local2": "でじたるちょう せんりゃくそしきぐるーぷ かいけいたんとう",
  "domain_name": "myna.go.jp",
  "name_servers": [
    "ns-1048.awsdns-03.org",
    "ns-1605.awsdns-08.co.uk",
    "ns-680.awsdns-21.net",
    "ns-432.awsdns-54.com"
  ],
  "status": {
    "ok": true,
    "registered": false,
    "connected": true,
    "user_reserved": false,
    "advance_registered": false,
    "renamed": false,
    "to_be_deleted": false,
    "deleted": false,
    "negotiated": false
  }
}

$ whois2 google.co.kr | jq
{
  "publish_status": "Y",
  "expiration": "2024/07/28 00:00:00 +0828",
  "updated": "2010/10/04 00:00:00 +0828",
  "created": "1999/07/28 00:00:00 +0828",
  "admin_phone": "82.25319000",
  "admin_email": "dns-admin@google.com",
  "registrant_zip_code": "135984",
  "registrant_address": "22nd Floor Gangnam Finance Center 737, Yeoksam-dong Kangnam-ku Seoul",
  "registrant_name": "Google Korea, LLC",
  "domain_name": "google.co.kr",
  "registrant_address_local": "서울시 강남구 역삼동 737 강남파이낸스센터 22층",
  "registrant_name_local": "구글코리아유한회사",
  "dnssec": "unsigned",
  "name_servers": [
    "ns1.google.com",
    "ns2.google.com",
    "ns3.google.com",
    "ns4.google.com"
  ]
}

$ whois2 google.com | jq
{
  "dnssec": "unsigned",
  "tech_email": "Select Request Email Form at https://domains.markmonitor.com/whois/google.com",
  "tech_country": "US",
  "tech_organization": "Google LLC",
  "admin_email": "Select Request Email Form at https://domains.markmonitor.com/whois/google.com",
  "admin_country": "US",
  "admin_organization": "Google LLC",
  "registrant_email": "Select Request Email Form at https://domains.markmonitor.com/whois/google.com",
  "registrant_country": "US",
  "registrant_organization": "Google LLC",
  "registrar_phone": "+1.2086851750",
  "registrar_email": "abusecomplaints@markmonitor.com",
  "registrar_id": "292",
  "registrar_name": "MarkMonitor, Inc.",
  "expiration": "2028/09/13 07:00:00 +0000",
  "created": "1997/09/15 07:00:00 +0000",
  "updated": "2019/09/09 15:39:04 +0000",
  "registrar_whois_url": "http://www.markmonitor.com",
  "registrar_whois_server": "whois.markmonitor.com",
  "registry_domain_id": "2138514_domain_com-vrsn",
  "domain_name": "google.com",
  "registrant_address": "CA",
  "admin_address": "CA",
  "tech_address": "CA",
  "name_servers": [
    "ns1.google.com",
    "ns3.google.com",
    "ns4.google.com",
    "ns2.google.com"
  ],
  "status": {
    "auto_renew_period": false,
    "inactive": false,
    "ok": false,
    "pending_create": false,
    "pending_delete": false,
    "pending_renew": false,
    "pending_restore": false,
    "pending_transfer": false,
    "pending_update": false,
    "redemption_period": false,
    "renew_period": false,
    "server_delete_prohibited": true,
    "server_hold": false,
    "server_renew_prohibited": false,
    "server_transfer_prohibited": true,
    "server_update_prohibited": true,
    "transfer_period": false,
    "client_delete_prohibited": true,
    "client_hold": false,
    "client_renew_prohibited": false,
    "client_transfer_prohibited": true,
    "client_update_prohibited": true
  }
}

Library

from pywhois2 import Whois
import json
import datetime


def json_serial(obj):
    if isinstance(obj, (datetime.datetime, datetime.date)):
        return obj.strftime("%Y/%m/%d %H:%M:%S %z")
    # 上記以外はサポート対象外.
    raise TypeError("Type %s not serializable" % type(obj))


whois = Whois('unko.co.jp')
result = whois.get()

print(json.dumps(result, default=json_serial))

use template file(ttp command)

$ git clone https://github.com/blacknon/pywhois2
$ cd pywhois2
$ whois google.jp | awk '/^# whois.jprs.jp/,/FAX番号/{print}' > /tmp/example.jp.txt
$ ttp -d /tmp/example.jp.txt -t ./pywhois2/templates/cctld/jp.tpl -o raw
[{'contact_zip_code': '94043', 'contact_email': 'dns-admin@google.com', 'contact_name': 'Google LLC', 'contact_name_local': 'Google LLC', 'updated': datetime.datetime(2023, 6, 1, 1, 5, 7, tzinfo=datetime.timezone(datetime.timedelta(seconds=32400))), 'expiration': datetime.datetime(2024, 5, 31, 0, 0, tzinfo=datetime.timezone(datetime.timedelta(seconds=32400))), 'created': datetime.datetime(2005, 5, 30, 0, 0, tzinfo=datetime.timezone(datetime.timedelta(seconds=32400))), 'registrant_name': 'Google LLC', 'registrant_name_local': 'Google LLC', 'domain_name': 'google.jp', 'name_servers': ['ns1.google.com', 'ns2.google.com', 'ns3.google.com', 'ns4.google.com'], 'status': {'ok': True, 'hold': False, 'to_be_suspended': False, 'suspended': False}, 'contact_address': 'Mountain View, 1600 Amphitheatre Parkway, CA', 'contact_fax': '16502530001', 'contact_phone': '16502530000', 'contact_address_local': 'Mountain View 1600 Amphitheatre Parkway CA'}]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywhois2-0.1.2.tar.gz (73.1 kB view details)

Uploaded Source

Built Distribution

pywhois2-0.1.2-py3-none-any.whl (187.4 kB view details)

Uploaded Python 3

File details

Details for the file pywhois2-0.1.2.tar.gz.

File metadata

  • Download URL: pywhois2-0.1.2.tar.gz
  • Upload date:
  • Size: 73.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pywhois2-0.1.2.tar.gz
Algorithm Hash digest
SHA256 63cce4b54c028a3265f50da2671abbfcff63b7a997302d2e22a6d53e3759b54b
MD5 5dd889b11de4648051296b7ac9d74058
BLAKE2b-256 f1216bc45cc8b2add16e5cfd86458691add058164643a49af976a5a88253684d

See more details on using hashes here.

File details

Details for the file pywhois2-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pywhois2-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 187.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pywhois2-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1c57b4d17ddc89163a133fc22c08cb850e34ba4e988a7e4982bbf7c60da65308
MD5 c5bd55cd5e561a4556b88fa9d711e662
BLAKE2b-256 21beb18be4dd5adab2f06ae6be311574d995c07367d958c75880b1dd48d30753

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page