File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ ## DNS Record
2+
3+ This script takes the website name as input and returns its dns records.
4+
5+ #Requirements to run this file:
6+
7+ External library called dnspython has been used here and it can be installed easily by using the following command:
8+
9+ pip install -r requirements.txt
10+
11+ #How to use this script?
12+
13+ 1.Install the requirements.
14+
15+ 2 . Type the following command
16+
17+ python dns_record.py
18+
19+ 3.It will ask for a website:
20+
21+ You can give any website name for example: google.com
Original file line number Diff line number Diff line change 1+ #Simple program to fetch dns record of a given website
2+
3+ import json
4+ import dns .resolver
5+
6+ #Dictionary to store the dns record of a website
7+ dns_record = {}
8+
9+ #User defined website
10+ website = input ("Enter the name of the website: " )
11+
12+ #Fetching the 'A' record of the website and storing it in the dictionary
13+ a_record = dns .resolver .resolve (website , 'A' )
14+ for ipval in a_record :
15+ dns_record ['A_Record_IP' ] = ipval .to_text ()
16+
17+ #List to store the mx records of a website
18+ mx_record_list = []
19+
20+ #Fetching the mx records and storing them in the dictionary
21+ mx_record = dns .resolver .resolve (website ,'MX' )
22+ for server in mx_record :
23+ mx_record_list .append (server )
24+ for i , element in enumerate (mx_record_list ):
25+ dns_record ['MX_Record' , i + 1 ] = element
26+
27+ #Displaying the record on the screen
28+ for key ,value in dns_record .items ():
29+ print (f"{ key } = { value } " )
30+
Original file line number Diff line number Diff line change 1+ dnspython == 2.0.0
You can’t perform that action at this time.
0 commit comments