How to resolve blockchain DNS using Python Requests

0 votes
There are certain blockchain domains that are resolved only by blockchain DNS resolvers.

If you try to open such a link in a browser, it won’t get resolved.

However, if you install a compatible browser plugin that supports blockchain DNS, the site will open smoothly.

I want to scrape some data from this site using Python Requests (browserless) and have no idea how to resolve such blockchain domains. Any help would be highly appreciated.
Aug 17, 2018 in Blockchain by sabby
• 4,370 points
2,143 views

1 answer to this question.

0 votes

You could use one of their publicly available apis to resolve the domain and obtain an ip. You'll find a list of api urls in the Firefox or Chrome addon script, in common.js.
A python 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://example.com/r/', 'https://example.us/r/', 'https://example.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://example.com')
if ip:
    r = requests.get('http://'+ip)
answered Aug 20, 2018 by Omkar
• 69,180 points

Related Questions In Blockchain

0 votes
1 answer

How to resolve Blockchain DNS using Python Requests?

Look at this example: import requests from random import ...READ MORE

answered Aug 22, 2018 in Blockchain by Christine
• 15,750 points
1,789 views
0 votes
1 answer

How to resolve blockchain dns using Python Requests

BDNS is offline and I don't know if ...READ MORE

answered Apr 7, 2022 in Blockchain by Aditya
• 7,680 points
1,253 views
0 votes
1 answer

How to interact with blockchain using Java web app?

You can interact with the blockchain using ...READ MORE

answered Jul 16, 2018 in Blockchain by digger
• 26,740 points
1,489 views
0 votes
1 answer

How to build a non-payment application using Ethereum blockchain?

I hope the following link is helpful ...READ MORE

answered Jul 17, 2018 in Blockchain by digger
• 26,740 points
991 views
0 votes
1 answer

Python request module for bitcoin json rpc

This should work: #!/usr/bin/env python import getpass import json import requests ...READ MORE

answered Aug 28, 2018 in Blockchain by digger
• 26,740 points
2,641 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,750 points
2,250 views
+1 vote
1 answer
+2 votes
1 answer
0 votes
1 answer

How to change "gasLimit" on Azure private blockchain?

Before deploying your network on Azure you ...READ MORE

answered Jul 3, 2018 in Blockchain by Omkar
• 69,180 points
1,075 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP