-
Notifications
You must be signed in to change notification settings - Fork 0
/
selenium_scraper.py
57 lines (51 loc) · 1.65 KB
/
selenium_scraper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from main import get_bird_names
import time
from menu import print_menu
import random
chrome_options = Options()
chrome_options.add_argument #("--headless")
browser = webdriver.Chrome(chrome_options=chrome_options)
url = 'https://www.name.com/domain/search/domain'
name_list = get_bird_names()
while True:
print("----------------------------------")
print("SEARCHING...")
print("----------------------------------")
n = random.randint(0, len(name_list) - 1)
domain_name = name_list[n]
url = 'https://www.name.com/domain/search/' + domain_name + ".com"
browser.get(url)
time.sleep(2)
available = ''
try:
available = browser.find_element_by_xpath('/html/body/div[3]/div/div[1]/div[5]/div/div[1]/div/div/div[1]/div/div[1]/span/span[2]').text
except:
pass
print(available)
if available == 'available' or available == 'Domain':
print(domain_name + ".com" + " is available!")
print_menu()
user_input = input(": ").rstrip()
while True:
try:
user_input = int(user_input)
break
except:
user_input = input(": ").rstrip()
continue
if user_input == 1:
# implement stuff
new_browser = webdriver.Chrome()
new_browser.get(url)
continue
if user_input == 2:
# implement stuff
pass
if user_input == 3:
# implement stuff
break
else:
print(domain_name + ".com" + " is taken!")
continue