-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfake.py
More file actions
183 lines (145 loc) · 6.88 KB
/
fake.py
File metadata and controls
183 lines (145 loc) · 6.88 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from faker import Faker as faker
from selenium import webdriver
from random import randrange
from time import sleep
import pathlib, os
#account = input("Insert account name: ")
#account = "myAccount"
current_email = ""
autenthication_code = ""
def print_file(username, password, email):
current_path = pathlib.Path().absolute()
myuser = username + username
with open(os.path.join(current_path + "/instagram_tools_accounts/", "accounts.txt"), 'a') as f:
f.write(myuser + " " + password + " " + email + "\n")
if __name__ == '__main__':
try:
chrome_options = Options()
#chrome_options.add_argument("--incognito")
chrome_options.add_argument("user-data-dir=selenium")
browser = webdriver.Chrome(options=chrome_options)
browser.get("http://it.emailfake.com")
sleep(2)
#get current email
current_email = browser.find_element_by_xpath("/html/body/div[3]/div/div/b/span").text
print("\n")
print(current_email)
#second tab
browser.execute_script("window.open('');")
browser.switch_to.window(browser.window_handles[1])
browser.get("http://instagram.com")
sleep(2)
# accept cookies: not useful now because i already save cookies as default
try:
cookies = browser.find_element_by_xpath("/html/body/div[2]/div/div/div/div[2]/button[1]")
cookies.click()
print("cookies")
except NoSuchElementException:
pass
# register
browser.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[2]/div/p/a/span").click()
print("register")
sleep(2)
fake = faker()
# email
browser.find_element_by_xpath("//input[@name=\"emailOrPhone\"]").send_keys(current_email)
print("email")
# name and surname
name = fake.name()
browser.find_element_by_xpath("//input[@name=\"fullName\"]").send_keys(name)
print("name")
# username #todo: get better with trycatch
username = fake.user_name() + str(randrange(10)) + str(randrange(10)) #johnwic98, then x2
browser.find_element_by_xpath("//input[@name=\"username\"]").send_keys(username+username)
print("username")
# password
password = fake.password()
browser.find_element_by_xpath("/html/body/div[1]/section/main/div/article/div/div[1]/div/form/div[6]/div/label/input").send_keys(password)
print("password")
# submit
browser.find_element_by_xpath("/html/body/div[1]/section/main/div/article/div/div[1]/div/form/div[7]/div/button").click()
print("submit")
sleep(2)
# change date and select valid year
browser.find_element_by_xpath("/html/body/div[1]/section/main/div/article/div/div[1]/div/div[4]/div/div/span/span[3]/select").send_keys("2001")
print("date")
# submit
browser.find_element_by_xpath("/html/body/div[1]/section/main/div/article/div/div[1]/div/div[6]/button").click()
print("submit")
sleep(2)
# back to the other tab
browser.switch_to.window(browser.window_handles[0])
browser.get("http://it.emailfake.com")
print("switched page to wait code")
# get autenthication_code
autenthication_code = WebDriverWait(browser, 20).until(EC.presence_of_element_located((By.XPATH, "/html/body/div[4]/div/div/div/div[2]/div[2]/div[4]/div[3]/table/tbody/tr/td/table/tbody/tr[4]/td/table/tbody/tr/td/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[2]"))).text
print("code: " + str(autenthication_code))
browser.switch_to.window(browser.window_handles[1])
sleep(2)
code = "'" + autenthication_code + "'"
browser.execute_script("document.getElementsByName('email_confirmation_code')[0].sendKeys("+ code +");")
submit = browser.find_element_by_xpath('//button[@type="submit"]')
browser.execute_script("arguments[0].click();", submit)
# BUG here
# BUG here
# BUG here
# BUG here
# BUG here
# BUG here
# BUG here
# BUG here
# BUG here
# BUG here
response = browser.find_element_by_xpath("/html/body/div[1]/section/main/div/article/div/div[1]/div[2]/form/div/div[4]/div").text
print(response)
sleep(10)
# ask new code
#browser.find_element_by_xpath("/html/body/div[1]/section/main/div/article/div/div[1]/div[1]/div[2]/div/button").click()
# not now notifications
browser.find_element_by_xpath("/html/body/div[4]/ div/div/div/div[3]/button[2]").click()
print("notifications")
sleep(1)
# search for account
browser.find_element_by_xpath("/html/body/div[1]/section/nav/div[2]/div/div/div[2]/div/div").send_keys(account)
print("account")
sleep(3)
# click on account
browser.find_element_by_xpath("/html/body/div[1]/section/nav/div[2]/div/div/div[2]/div[3]/div[2]/div/a[1]/div").click()
print("click on " + str(account))
sleep(3)
# click on first pic
browser.find_element_by_xpath("/html/body/div[1]/section/main/div/div[3]/article/div[1]/div/div[1]/div[1]/a/div[1]/div[2]").click()
print("first pic")
sleep(3)
# like last *times* pics
times = 0
for times in range(10):
# like pic
browser.find_element_by_xpath("/html/body/div[5]/div[2]/div/article/div[3]/section[1]/span[1]/button/div/span/svg").click()
# get description
description = browser.find_element_by_xpath("/html/body/div[5]/div[2]/div/article/div[3]/div[1]/ul/div/li/div/div/div[2]/span").text
print("liked pic with description: [" + str(description) + "]")
sleep(3)
# next
browser.find_element_by_xpath("/html/body/div[5]/div[1]/div/div/a").click()
# close pics
browser.find_element_by_xpath("/html/body/div[5]/div[3]/button/div/svg/path").click()
print("close pics")
# settings
browser.find_element_by_xpath("/html/body/div[1]/section/nav/div[2]/div/div/div[3]/div/div[5]/span/img").click()
sleep(1)
# exit account
browser.find_element_by_xpath("/html/body/div[1]/section/nav/div[2]/div/div/div[3]/div/div[5]/div[2]/div/div[2]/div[2]/div[2]/div/div/div/div/div/div").click()
print("exited from " +str(account))
sleep(3)
print("Disconnecting...")
browser.close()
except Exception as e:
print(e)