Look at this example:
import requests
from random import choice
def domain_ip(domain):
'''Uses bdns api to resolve domain names'''
domain = domain.split('/')[2] if '://' in domain else domain
apis = ['https://bdns.co/r/', 'https://bdns.us/r/', 'https://bdns.bz/r/']
api = choice(apis)
r = requests.get(api+domain)
if r.status_code == 200:
ip = r.text.splitlines()[0]
print("Domain: {} IP: {}".format(domain, ip))
return ip
else:
print('HTTP Error: {}'.format(r.status_code))
ip = domain_ip('http://jstash.bazar')
if ip:
r = requests.get('http://'+ip)
You could use one of their publicly available apis to resolve the domain and obtain an ip. Here is a list of API URLs: https://github.com/B-DNS/Firefox/blob/master/common.js#L54