def __init__(self, username, password, token, headless=True): self.url = 'https://instagram.com/' self.selectors = { 'username_field': 'username', 'password_field': 'password', 'button_login': '******', 'search_user': '******', 'select_user': '******', 'next_step': '//div[text()="Далее"]', 'message_field': '*//textarea', 'textarea': 'textarea', 'send': '//button[text()="Отправить"]' } # Selenium config opts = webdriver.ChromeOptions() opts.add_argument("user-agent=PhantomJS") prefs = {"profile.default_content_setting_values.notifications": 2} opts.add_experimental_option("prefs", prefs) opts.add_argument('user-data-dir=' + conf.get_sessions_path() + '/' + token) opts.binary_location = conf.get_chromium_path() if headless: opts.add_argument('headless') self.driver = webdriver.Chrome(conf.get_driver_path(), options=opts) try: self.login(username, password) except Exception as e: logging.error(e)
def __init__(self, token, headless=False): self.url = 'https://web.whatsapp.com/' self.selectors = { 'select_contact': 'div[role="option"]', 'input_field': 'div.selectable-text', 'send': 'span[data-testid="send"]' } # Selenium config opts = webdriver.ChromeOptions() prefs = {"profile.default_content_setting_values.notifications": 2} opts.add_experimental_option("prefs", prefs) opts.add_argument('user-data-dir=' + conf.get_sessions_path() + '/' + token) opts.binary_location = conf.get_chromium_path() if headless: opts.add_argument('headless') self.driver = webdriver.Chrome(conf.get_driver_path(), options=opts)
def get_path(id): return config.get_sessions_path() + str(id)
def create(): sessionid = datetime.now().strftime('%Y%m%d%H%m%s%f') return filehelper.create_filename(config.get_sessions_path(), sessionid)