Skip to content

Instantly share code, notes, and snippets.

@m0pfin
Created October 9, 2020 11:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m0pfin/bbd4f5724e31b6f1cb765a9ee4827f7f to your computer and use it in GitHub Desktop.
Save m0pfin/bbd4f5724e31b6f1cb765a9ee4827f7f to your computer and use it in GitHub Desktop.
Mass IMPORT cookies to INDIGO & MultiLoginApp
import sys
import zipfile
import os
import re
import shutil
import requests
# Директория с аккаунтами
directory = '/Applications/MAMP/htdocs/indigos/acc/'
# Получаем список файлов
files = os.listdir(directory)
# Считаем колл-во файлов
count = len(files)
# Задаём нулевое значение счетчику для создание профилей
count_profile = 0
for line in files:
line = line.strip()
# Название архива
zip_name = line
print('Название архива: %s' % (zip_name))
# Перехватываем ошибки
try:
# Обрезаем расширение
str_name_folder = zip_name
str_name_folder = re.sub(r"\.zip$", '', str_name_folder)
# Читаем содержимое архива
z = zipfile.ZipFile(directory+str(zip_name), 'r')
name_cookies = str_name_folder+'/Cookies/Google_[Chrome]_Default.txt' # Задаём имя в котором хранятся куки, если папки нет удалить str_name_folder
z.extract(name_cookies) # Извлечь файл из архива
# прочитаем файл построчно
profile = open('profile_id.txt', 'r')
lines = profile.readlines()
profile_id = lines[0].strip()
print('ID профиля: %s' % (profile_id))
# f = open('cookies'+str(i)+'.txt')
f = open(name_cookies)
print(f)
cook = f.read()
# print(cook)
url = "http://127.0.0.1:35000/api/v1/profile/cookies/import/netscape?profileId=" + profile_id
payload = cook
headers = {
'Content-Type': 'text/plain'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text.encode('utf8'))
# запишем файл построчно пропустив первую строку чтобы очистить список profile_id.txt
profile = open('profile_id.txt', 'w')
profile.writelines(lines[1:])
# Удаляем директорию после использования
# path = os.path.join(os.path.abspath(os.path.dirname(__file__)), str_name_folder)
# shutil.rmtree(path)
# Иногда задаём такое имя
# name_cookies = 'Cookies/Cookies.txt'
# Считаем колл-во профилей для создания
count_profile += 1
except Exception:
print('Это не архив')
# z = zipfile.ZipFile(directory+'Архив.zip', 'r')
# z.extract(name_cookies) # Извлечь файл из архива
#
# f = open(name_cookies)
# cook = f.read()
# #print(cook)
# Сколько всего профилей создать
# print(count_profile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment