Created
September 20, 2020 07:59
-
-
Save m0pfin/a1b7d8d5dd9af49871ef5ef1aac58b41 to your computer and use it in GitHub Desktop.
AEZAKMI: Automate token extract & Login account
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
from selenium.common.exceptions import TimeoutException | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.support.ui import Select | |
import time | |
import sys | |
prof_num = sys.argv[1] | |
fb_login = sys.argv[2] | |
fb_password = sys.argv[3] | |
profile_number = 2 #номер браузера, который вы хотите запускать | |
user_profile_number = prof_num #номер профиля, который вы хотите запускать | |
# Вместо m0pfin ваш логин на MacOS | |
PROFILE_NUMBER_STRING = str(profile_number)+'/' | |
EXTENTION_DIR = '/Users/m0pfin/Library/Application Support/Aezakmi/core/' | |
USERDATA_DIR = '/Users/m0pfin/Library/Application Support/Aezakmi/Profiles/' | |
options = Options() | |
options.binary_location = '/Applications/Aezakmi/Aezakmi '+str(profile_number)+'.app/Contents/MacOS/Chromium' | |
options.add_argument('--disable-infobars') | |
options.add_argument('--load-extension=' + EXTENTION_DIR) | |
options.add_argument('--no-default-browser-check') | |
options.add_argument('--user-data-dir=' + USERDATA_DIR + PROFILE_NUMBER_STRING) | |
options.add_argument('account.aezakmi.run') | |
driver = webdriver.Chrome(options=options) | |
# заходим на страницу плагина и вводим логин и пароль | |
driver.get("chrome-extension://fmklgidcemllamkndiefdhnkjgmommce/index.html#/dashboard") | |
login = driver.find_element_by_id("login") | |
password = driver.find_element_by_id("password") | |
login.send_keys("ТУТ_ЛОГИН") # Aezakmi login | |
password.send_keys("ТУТ_ПАРОЛЬ") # Aezakmi pass | |
driver.find_element_by_xpath("/html/body/div/div/div/div/div/form/div/button[1]").click() | |
delay = 3 | |
try: | |
users_profiles = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.XPATH, '//*[@id="users-profiles"]/option[2]'))) | |
except TimeoutException: | |
print("Loading took too much time!") | |
# выбираем нужный профиль пользователя (по порядковому номеру) | |
select = Select(driver.find_element_by_id('users-profiles')) | |
select.select_by_index(user_profile_number) | |
start_profile = driver.find_elements_by_xpath("//*[contains(text(), 'A-E-Z-A-K-M-I')]") | |
start_profile[0].click() | |
time.sleep(7) | |
# переходим в гугл | |
driver.get('https://www.facebook.com/login') | |
login = driver.find_element_by_id("email") | |
password = driver.find_element_by_id("pass") | |
login.send_keys(fb_login) # Логин аккаунта ФБ | |
password.send_keys(fb_password) # Пасс аккаунта ФБ | |
driver.find_element_by_id("loginbutton").click() | |
time.sleep(5) | |
driver.get('https://www.facebook.com/ads/create') | |
time.sleep(3) | |
content = driver.execute_script("var re=/EAABsbCS1[a-zA-Z0-9]*/,m=document.documentElement.innerHTML.match(re);function copyToClipboard(b){var a=document.createElement(\"input\");a.value=\"undefined\"==typeof b?window.location.href:b;document.body.appendChild(a);a.select();document.execCommand(\"copy\");document.body.removeChild(a)}\"undefined\"!==m[0]?(copyToClipboard(m[0]),prompt(\"Токен скопирован в буфер обмена\",m[0])):alert(\"Токен не найден. Перейдите в facebook.com/adsmanager\");").text() | |
print (content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment