Septzzz's picture
Upload folder using huggingface_hub (part 9)
9cabd68 verified
Raw
History Blame Contribute Delete
4.93 kB
import requests
import json
from datetime import date, datetime, timedelta
import os
from typing import Optional, Dict, Union, List
def as_details(as_number: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"This includes information such as the AS Size, Number of records, time of cache, and name,
Data is cached and can be up to 1 day old."
"""
url = f"https://asn.p.rapidapi.com/json/details/{as_number}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "asn.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def as_archive(as_timestamp: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Using AS Snapshot, you can get the requested {as-timestamp}. This will give you a look back in time at the announced IPs of an ASN at that timestamp.
dups field indicates timestamps with the same data."
"""
url = f"https://asn.p.rapidapi.com/json/archive/{as_timestamp}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "asn.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def as_snapshots(as_number: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"A list of AS Details over time."
"""
url = f"https://asn.p.rapidapi.com/json/snapshots/{as_number}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "asn.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def as_details_ip_list(as_number: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"This is a combination lookup that includes AS Details, and a short and sweet IP List of announced IP subnets.
Data is cached up to 1 day before being updated."
"""
url = f"https://asn.p.rapidapi.com/json/detailslist/{as_number}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "asn.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def ips(as_number: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Get a list of the current announced IPs of a subnet in a detailed form.
Data is cached up to 1 day before being updated."
"""
url = f"https://asn.p.rapidapi.com/json/raw/{as_number}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "asn.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def as_details_ips(as_number: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"A combination lookup that includes details on the AS, and the annouced IPs fully broken out.
Data is cached for a day before being updated."
"""
url = f"https://asn.p.rapidapi.com/json/detailsraw/{as_number}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "asn.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def ip_list(as_number: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Get a list of all IPs that an ASN annouces.
Results can be up to 1 day old."
"""
url = f"https://asn.p.rapidapi.com/json/list/{as_number}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "asn.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation