Skip to content

Commit f2625a2

Browse files
authored
HarshCasper#943 Domain Name Availability (HarshCasper#1009)
* HarshCasper#943 Files Added * Update Domain_name.py * Update README.md * Update requirements.txt * Create .env.example
1 parent ac13199 commit f2625a2

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
2+
API_SECRET = "XXXXXXXXXXXXXXXXXXXXXX"
3+
4+
// Here you have to save your own Private Access API and Secret Key which will be used in Main code to fetch the data
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import requests
2+
import decouple
3+
4+
req_headers = {}
5+
6+
7+
def godaddy_credentials():
8+
"""
9+
This functions reads your credentials from .env file
10+
"""
11+
global req_headers
12+
13+
print("\n\t::: Reading Godaddy Credentials :::")
14+
15+
api_key = decouple.config("API_KEY")
16+
api_secret = decouple.config("API_SECRET")
17+
# api_key = input("\nEnter your API Key: ")
18+
# api_secret = input("Enter your SECRET Key: ")
19+
20+
req_headers = {
21+
"Authorization": f"sso-key {api_key}:{api_secret}",
22+
"accept": "application/json"
23+
}
24+
25+
26+
def get_url(domain_name):
27+
"""
28+
creating the required URL from domain name
29+
:param domain_name: (string) domain name
30+
:return: URL
31+
"""
32+
return f"https://api.ote-godaddy.com/v1/domains/suggest?query={domain_name}&country=IN&waitMs=1000"
33+
34+
35+
def available_domain_names():
36+
"""
37+
This function takes godaddy credentials from the user and generates all the
38+
available domain names in a text file.
39+
"""
40+
godaddy_credentials()
41+
domain_name = input("\nEnter required DOMAIN Name: ")
42+
url = get_url(domain_name)
43+
44+
print("\nSearching for the available domains")
45+
res = requests.get(url, headers=req_headers)
46+
47+
if res.status_code == 200:
48+
# Output is in JSON file so reading it.
49+
response = res.json()
50+
51+
# Saving our available domains in a text file.
52+
print(f"\nSaving all the available domain names in {domain_name}.txt file")
53+
f = open(f"{domain_name}.txt", "a")
54+
for i in response:
55+
f.writelines(i['domain'] + '\n')
56+
f.close()
57+
print(f"\nFile {domain_name}.txt saved successfully in your current directory")
58+
59+
else:
60+
print("Error Status Code")
61+
62+
63+
if __name__ == "__main__":
64+
available_domain_names()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Domain Name Availabilty Checker
2+
3+
- The python script uses GoDaddy's API to get all the domain names which are available according to the keyword given by user.
4+
- All the results are stored in a ```.txt``` file, named after the keyword.
5+
6+
7+
## Setup
8+
9+
- A virtual environment.
10+
- `pip install -r requirements.txt`
11+
- Generate your GoDaddy API KEY and Secret KEY from [here](https://developer.godaddy.com/keys)
12+
- Paste the token in a `.env` file (Take [`.env.example`](.env.example) as an example)
13+
14+
## Running the script:
15+
16+
17+
```sh
18+
$ python Domain_name.py
19+
```
20+
21+
## Working screenshots:
22+
23+
![Image](https://i.imgur.com/mZcXwJZ.png)
24+
25+
![Image](https://i.imgur.com/BUzocy9.png)
26+
27+
## Author:
28+
29+
[Akhil Bhalerao](https://github.com/iamakkkhil)
30+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
certifi==2020.12.5
2+
chardet==4.0.0
3+
idna==2.10
4+
python-decouple==3.4
5+
requests==2.25.1
6+
urllib3==1.26.4

0 commit comments

Comments
 (0)