-
Notifications
You must be signed in to change notification settings - Fork 6
/
Ibot.py
52 lines (43 loc) · 1.56 KB
/
Ibot.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
import time
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver.common.by import By
from auth import user, passwd
userid = user
passwd = passwd
d = DesiredCapabilities.CHROME
d['goog:loggingPrefs'] = { 'performance':'ALL' }
# to open the chromebrowser
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_experimental_option('w3c', True)
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(desired_capabilities=d, options=chrome_options)
driver.get("https://www.instagram.com/")
time.sleep(5)
driver.find_element(By.CSS_SELECTOR, "div._ab32:nth-child(1) > div:nth-child(1) > label:nth-child(1) > input:nth-child(2)").send_keys(userid)
driver.find_element(By.CSS_SELECTOR, "div._ab32:nth-child(2) > div:nth-child(1) > label:nth-child(1) > input:nth-child(2)").send_keys(passwd)
driver.find_element(By.CSS_SELECTOR, "div._abak:nth-child(3)").click()
time.sleep(10)
s = driver.get_log("performance")
s = str(s).split(',')
with open('session.txt','w') as kz:
for m in s:
if 'sessionid' in m:
m = m.split('Secure')
p = str(m).split('=')
print(p,file=kz)
print(p)
pz = []
with open('session.txt','r') as l:
for mz in l:
mz = mz.split(']')
pz.append(mz)
for sm in pz[7:10]:
sm = str(sm).split(',')
if '%' in sm[4]:
imp = sm[4]
sz = imp[3:]
(f,s) = str(sz).split(';')
print(f)