mirror of
https://github.com/C24Be/AS_Network_List.git
synced 2026-01-25 15:31:12 +03:00
Add whois short infor per AS
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
import argparse
|
import argparse
|
||||||
|
from cymruwhois import Client
|
||||||
|
|
||||||
def get_as_prefixes(asn):
|
def get_as_prefixes(asn):
|
||||||
url = f"https://stat.ripe.net/data/announced-prefixes/data.json?resource={asn}"
|
url = f"https://stat.ripe.net/data/announced-prefixes/data.json?resource={asn}"
|
||||||
@@ -13,6 +14,11 @@ def get_as_prefixes(asn):
|
|||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
def get_as_whois(asn):
|
||||||
|
c = Client()
|
||||||
|
r = c.lookup(asn)
|
||||||
|
return r.owner
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='./as_network_list.py -q AS61280')
|
parser = argparse.ArgumentParser(description='./as_network_list.py -q AS61280')
|
||||||
parser.add_argument('asn', help='The AS number to get prefixes for.')
|
parser.add_argument('asn', help='The AS number to get prefixes for.')
|
||||||
@@ -21,9 +27,11 @@ def main():
|
|||||||
|
|
||||||
asn = args.asn
|
asn = args.asn
|
||||||
prefixes = get_as_prefixes(asn)
|
prefixes = get_as_prefixes(asn)
|
||||||
|
whois_info = get_as_whois(asn)
|
||||||
|
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
print(f"Prefixes announced by {asn}:")
|
print(f"Prefixes announced by {asn}:")
|
||||||
|
print(f"Whois info for {asn}: {whois_info}")
|
||||||
|
|
||||||
for prefix in prefixes:
|
for prefix in prefixes:
|
||||||
print(prefix)
|
print(prefix)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
certifi==2024.2.2
|
certifi==2024.2.2
|
||||||
charset-normalizer==3.3.2
|
charset-normalizer==3.3.2
|
||||||
|
cymruwhois==1.6
|
||||||
idna==3.6
|
idna==3.6
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
urllib3==2.2.1
|
urllib3==2.2.1
|
||||||
|
|||||||
Reference in New Issue
Block a user