Advertisement
Guest User

Untitled

a guest
Jan 29th, 2016
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 53.09 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. import os
  4. import sys
  5. import time
  6. from PyQt4 import QtCore
  7. from PyQt4 import QtGui
  8. import requests as http
  9. import urllib.request as urllib2
  10. from xml.etree.ElementTree import XML
  11. from selenium import webdriver
  12. from selenium.webdriver.common.by import By
  13. from selenium.webdriver.support.ui import WebDriverWait
  14. from selenium.webdriver.support import expected_conditions as EC
  15. from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  16. from selenium.webdriver.common.keys import Keys
  17. from PIL import Image
  18. import uuid
  19. import random
  20. import string
  21. import imaplib
  22. import email
  23. import re
  24. import traceback
  25. import quopri
  26. import datetime
  27.  
  28. try:
  29.     _fromUtf8 = QtCore.QString.fromUtf8
  30. except AttributeError:
  31.     def _fromUtf8(s):
  32.         return s
  33.  
  34. try:
  35.     _encoding = QtGui.QApplication.UnicodeUTF8
  36.  
  37.     def _translate(context, text, disambig):
  38.         return QtGui.QApplication.translate(context, text, disambig, _encoding)
  39. except AttributeError:
  40.     def _translate(context, text, disambig):
  41.         return QtGui.QApplication.translate(context, text, disambig)
  42.  
  43.  
  44. class Ui_Program(object):
  45.  
  46.     def setupUi(self, MainWindow):
  47.         MainWindow.setObjectName(_fromUtf8("MainWindow"))
  48.         MainWindow.resize(743, 480)
  49.         self.centralwidget = QtGui.QWidget(MainWindow)
  50.         self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
  51.         self.groupBox = QtGui.QGroupBox(self.centralwidget)
  52.         self.groupBox.setGeometry(QtCore.QRect(10, 10, 721, 111))
  53.         self.groupBox.setObjectName(_fromUtf8("groupBox"))
  54.         self.label = QtGui.QLabel(self.groupBox)
  55.         self.label.setGeometry(QtCore.QRect(10, 20, 101, 22))
  56.         self.label.setObjectName(_fromUtf8("label"))
  57.         self.label_2 = QtGui.QLabel(self.groupBox)
  58.         self.label_2.setGeometry(QtCore.QRect(120, 20, 121, 22))
  59.         self.label_2.setText(_fromUtf8(""))
  60.         self.label_2.setObjectName(_fromUtf8("label_2"))
  61.         self.pushButton = QtGui.QPushButton(self.groupBox)
  62.         self.pushButton.setGeometry(QtCore.QRect(250, 20, 101, 23))
  63.         self.pushButton.setObjectName(_fromUtf8("pushButton"))
  64.         self.label_3 = QtGui.QLabel(self.groupBox)
  65.         self.label_3.setGeometry(QtCore.QRect(370, 20, 101, 22))
  66.         self.label_3.setObjectName(_fromUtf8("label_3"))
  67.         self.label_4 = QtGui.QLabel(self.groupBox)
  68.         self.label_4.setGeometry(QtCore.QRect(480, 20, 121, 22))
  69.         self.label_4.setText(_fromUtf8(""))
  70.         self.label_4.setObjectName(_fromUtf8("label_4"))
  71.         self.pushButton_2 = QtGui.QPushButton(self.groupBox)
  72.         self.pushButton_2.setGeometry(QtCore.QRect(610, 20, 101, 23))
  73.         self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
  74.         self.label_5 = QtGui.QLabel(self.groupBox)
  75.         self.label_5.setGeometry(QtCore.QRect(10, 80, 101, 22))
  76.         self.label_5.setObjectName(_fromUtf8("label_5"))
  77.         self.lineEdit = QtGui.QLineEdit(self.groupBox)
  78.         self.lineEdit.setGeometry(QtCore.QRect(120, 80, 191, 22))
  79.         self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
  80.         self.pushButton_3 = QtGui.QPushButton(self.groupBox)
  81.         self.pushButton_3.setGeometry(QtCore.QRect(320, 80, 91, 23))
  82.         font = QtGui.QFont()
  83.         font.setBold(True)
  84.         font.setWeight(75)
  85.         self.pushButton_3.setFont(font)
  86.         self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
  87.         self.pushButton_4 = QtGui.QPushButton(self.groupBox)
  88.         self.pushButton_4.setGeometry(QtCore.QRect(420, 80, 91, 23))
  89.         self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
  90.         self.label_10 = QtGui.QLabel(self.groupBox)
  91.         self.label_10.setGeometry(QtCore.QRect(10, 50, 101, 22))
  92.         self.label_10.setObjectName(_fromUtf8("label_10"))
  93.         self.label_11 = QtGui.QLabel(self.groupBox)
  94.         self.label_11.setGeometry(QtCore.QRect(120, 50, 61, 22))
  95.         self.label_11.setText(_fromUtf8(""))
  96.         self.label_11.setObjectName(_fromUtf8("label_11"))
  97.         self.pushButton_9 = QtGui.QPushButton(self.groupBox)
  98.         self.pushButton_9.setGeometry(QtCore.QRect(190, 50, 101, 23))
  99.         self.pushButton_9.setObjectName(_fromUtf8("pushButton_9"))
  100.         self.pushButton_8 = QtGui.QPushButton(self.groupBox)
  101.         self.pushButton_8.setGeometry(QtCore.QRect(520, 80, 191, 23))
  102.         self.pushButton_8.setObjectName(_fromUtf8("pushButton_8"))
  103.         self.pushButton_10 = QtGui.QPushButton(self.groupBox)
  104.         self.pushButton_10.setGeometry(QtCore.QRect(450, 50, 101, 23))
  105.         self.pushButton_10.setObjectName(_fromUtf8("pushButton_10"))
  106.         self.label_12 = QtGui.QLabel(self.groupBox)
  107.         self.label_12.setGeometry(QtCore.QRect(300, 50, 101, 22))
  108.         self.label_12.setObjectName(_fromUtf8("label_12"))
  109.         self.label_13 = QtGui.QLabel(self.groupBox)
  110.         self.label_13.setGeometry(QtCore.QRect(390, 50, 51, 22))
  111.         self.label_13.setText(_fromUtf8(""))
  112.         self.label_13.setObjectName(_fromUtf8("label_13"))
  113.         self.label_14 = QtGui.QLabel(self.groupBox)
  114.         self.label_14.setGeometry(QtCore.QRect(560, 50, 61, 22))
  115.         self.label_14.setObjectName(_fromUtf8("label_14"))
  116.         self.comboBox = QtGui.QComboBox(self.groupBox)
  117.         self.comboBox.setGeometry(QtCore.QRect(628, 50, 81, 22))
  118.         self.comboBox.setObjectName(_fromUtf8("comboBox"))
  119.         self.comboBox.addItem(_fromUtf8(""))
  120.         self.comboBox.addItem(_fromUtf8(""))
  121.         self.groupBox_2 = QtGui.QGroupBox(self.centralwidget)
  122.         self.groupBox_2.setGeometry(QtCore.QRect(10, 130, 351, 301))
  123.         self.groupBox_2.setObjectName(_fromUtf8("groupBox_2"))
  124.         self.pushButton_5 = QtGui.QPushButton(self.groupBox_2)
  125.         self.pushButton_5.setGeometry(QtCore.QRect(10, 270, 151, 23))
  126.         self.pushButton_5.setObjectName(_fromUtf8("pushButton_5"))
  127.         self.pushButton_6 = QtGui.QPushButton(self.groupBox_2)
  128.         self.pushButton_6.setGeometry(QtCore.QRect(190, 270, 151, 23))
  129.         self.pushButton_6.setObjectName(_fromUtf8("pushButton_6"))
  130.         self.textEdit = QtGui.QTextEdit(self.groupBox_2)
  131.         self.textEdit.setGeometry(QtCore.QRect(10, 20, 331, 241))
  132.         self.textEdit.setLineWrapMode(QtGui.QTextEdit.NoWrap)
  133.         self.textEdit.setReadOnly(True)
  134.         self.textEdit.setObjectName(_fromUtf8("textEdit"))
  135.         self.groupBox_3 = QtGui.QGroupBox(self.centralwidget)
  136.         self.groupBox_3.setGeometry(QtCore.QRect(380, 130, 351, 301))
  137.         self.groupBox_3.setObjectName(_fromUtf8("groupBox_3"))
  138.         self.textBrowser_2 = QtGui.QTextBrowser(self.groupBox_3)
  139.         self.textBrowser_2.setGeometry(QtCore.QRect(10, 20, 331, 221))
  140.         self.textBrowser_2.setLineWrapMode(QtGui.QTextEdit.NoWrap)
  141.         self.textBrowser_2.setObjectName(_fromUtf8("textBrowser_2"))
  142.         self.label_6 = QtGui.QLabel(self.groupBox_3)
  143.         self.label_6.setGeometry(QtCore.QRect(10, 250, 131, 22))
  144.         self.label_6.setObjectName(_fromUtf8("label_6"))
  145.         self.label_7 = QtGui.QLabel(self.groupBox_3)
  146.         self.label_7.setGeometry(QtCore.QRect(150, 250, 191, 22))
  147.         self.label_7.setObjectName(_fromUtf8("label_7"))
  148.         self.label_8 = QtGui.QLabel(self.groupBox_3)
  149.         self.label_8.setGeometry(QtCore.QRect(10, 270, 131, 22))
  150.         self.label_8.setObjectName(_fromUtf8("label_8"))
  151.         self.label_9 = QtGui.QLabel(self.groupBox_3)
  152.         self.label_9.setGeometry(QtCore.QRect(150, 270, 191, 22))
  153.         self.label_9.setObjectName(_fromUtf8("label_9"))
  154.         MainWindow.setCentralWidget(self.centralwidget)
  155.         self.menubar = QtGui.QMenuBar(MainWindow)
  156.         self.menubar.setGeometry(QtCore.QRect(0, 0, 743, 21))
  157.         self.menubar.setObjectName(_fromUtf8("menubar"))
  158.         MainWindow.setMenuBar(self.menubar)
  159.         self.statusbar = QtGui.QStatusBar(MainWindow)
  160.         self.statusbar.setObjectName(_fromUtf8("statusbar"))
  161.         MainWindow.setStatusBar(self.statusbar)
  162.  
  163.         self.retranslateUi(MainWindow)
  164.         QtCore.QMetaObject.connectSlotsByName(MainWindow)
  165.  
  166.     def retranslateUi(self, MainWindow):
  167.         MainWindow.setWindowTitle(_translate("MainWindow", "Instagram Email Changer | by Orphx | Skype: minimatronik16", None))
  168.         self.groupBox.setTitle(_translate("MainWindow", "Настройки", None))
  169.         self.label.setText(_translate("MainWindow", "Файл с email\'ами #1:", None))
  170.         self.pushButton.setText(_translate("MainWindow", "Открыть", None))
  171.         self.label_3.setText(_translate("MainWindow", "Файл с email\'ами #2:", None))
  172.         self.pushButton_2.setText(_translate("MainWindow", "Открыть", None))
  173.         self.label_5.setText(_translate("MainWindow", "Ключ antigate:", None))
  174.         self.pushButton_3.setText(_translate("MainWindow", "СТАРТ", None))
  175.         self.pushButton_4.setText(_translate("MainWindow", "СТОП", None))
  176.         self.label_10.setText(_translate("MainWindow", "Файл с user-agents:", None))
  177.         self.pushButton_9.setText(_translate("MainWindow", "Открыть", None))
  178.         self.pushButton_8.setText(_translate("MainWindow", "Сохранить введенные данные", None))
  179.         self.pushButton_10.setText(_translate("MainWindow", "Открыть", None))
  180.         self.label_12.setText(_translate("MainWindow", "Файл с прокси:", None))
  181.         self.label_14.setText(_translate("MainWindow", "Тип прокси:", None))
  182.         self.comboBox.setItemText(0, _translate("MainWindow", "http", None))
  183.         self.comboBox.setItemText(1, _translate("MainWindow", "socks5", None))
  184.         self.groupBox_2.setTitle(_translate("MainWindow", "Готовые данные", None))
  185.         self.pushButton_5.setText(_translate("MainWindow", "Экспорт в TXT", None))
  186.         self.pushButton_6.setText(_translate("MainWindow", "Очистить", None))
  187.         self.groupBox_3.setTitle(_translate("MainWindow", "ЛОГ", None))
  188.         self.label_6.setText(_translate("MainWindow", "Баланс antigate:", None))
  189.         self.label_7.setText(_translate("MainWindow", "0$", None))
  190.         self.label_8.setText(_translate("MainWindow", "Загруженность antigate:", None))
  191.         self.label_9.setText(_translate("MainWindow", "0%", None))
  192.  
  193.  
  194. class Settings():
  195.     common_settings = QtCore.QSettings(
  196.         'settings/settings.ini', QtCore.QSettings.IniFormat)
  197.  
  198.  
  199. class Program(QtGui.QMainWindow,  Ui_Program):
  200.  
  201.     def __init__(self, parent=None):
  202.         super(Program, self).__init__(parent)
  203.         self.setupUi(self)
  204.         self.settings = Settings().common_settings
  205.         self.restore_settings()
  206.         self.pushButton_4.setEnabled(False)
  207.  
  208.         self.pushButton_3.clicked.connect(self.start_changing)
  209.         self.pushButton_8.clicked.connect(self.save_settings)
  210.         self.pushButton_5.clicked.connect(self.export_data)
  211.         self.pushButton_6.clicked.connect(self.clear_data)
  212.         self.pushButton.clicked.connect(self.open_email_1)
  213.         self.pushButton_2.clicked.connect(self.open_email_2)
  214.         self.pushButton_9.clicked.connect(self.open_useragents)
  215.         self.pushButton_10.clicked.connect(self.open_proxy)
  216.  
  217.     def open_email_1(self):
  218.         path = QtGui.QFileDialog.getOpenFileName(
  219.             self, u"Выберите файл с email #1", "", "TXT (*.txt)")
  220.         self.label_2.setText(path)
  221.  
  222.     def open_email_2(self):
  223.         path = QtGui.QFileDialog.getOpenFileName(
  224.             self, u"Выберите файл с email #2", "", "TXT (*.txt)")
  225.         self.label_4.setText(path)
  226.  
  227.     def open_useragents(self):
  228.         path = QtGui.QFileDialog.getOpenFileName(
  229.             self, u"Выберите файл с useragent", "", "TXT (*.txt)")
  230.         self.label_11.setText(path)
  231.  
  232.     def open_proxy(self):
  233.         path = QtGui.QFileDialog.getOpenFileName(
  234.             self, u"Выберите файл с proxy", "", "TXT (*.txt)")
  235.         self.label_13.setText(path)
  236.  
  237.     def clear_data(self):
  238.         self.textEdit.clear()
  239.  
  240.     def export_data(self):
  241.         path = QtGui.QFileDialog.getSaveFileName(
  242.             self, u"Выберите файл для экспорта в TXT", "", "TXT (*.txt)")
  243.         with open(path, "a") as fileforwrite:
  244.             fileforwrite.write(self.textEdit.toPlainText())
  245.  
  246.     def save_settings(self):
  247.         label_2name = self.label_2.objectName()
  248.         label_2 = self.label_2.text()
  249.         self.settings.setValue(label_2name, label_2)
  250.  
  251.         label_4name = self.label_4.objectName()
  252.         label_4 = self.label_4.text()
  253.         self.settings.setValue(label_4name, label_4)
  254.  
  255.         label_11name = self.label_11.objectName()
  256.         label_11 = self.label_11.text()
  257.         self.settings.setValue(label_11name, label_11)
  258.  
  259.         label_13name = self.label_13.objectName()
  260.         label_13 = self.label_13.text()
  261.         self.settings.setValue(label_13name, label_13)
  262.  
  263.         lineEditname = self.lineEdit.objectName()
  264.         lineEdit = self.lineEdit.text()
  265.         self.settings.setValue(lineEditname, lineEdit)
  266.  
  267.         comboBoxname = self.comboBox.objectName()
  268.         comboBox = self.comboBox.currentText()
  269.         self.settings.setValue(comboBoxname, comboBox)
  270.  
  271.         self.textBrowser_2.append("Настройки сохранены")
  272.  
  273.     def restore_settings(self):
  274.         label_2name = self.label_2.objectName()
  275.         value = str(self.settings.value(label_2name))
  276.         if value != "None":
  277.             self.label_2.setText(value)
  278.  
  279.         label_4name = self.label_4.objectName()
  280.         value = str(self.settings.value(label_4name))
  281.         if value != "None":
  282.             self.label_4.setText(value)
  283.  
  284.         label_11name = self.label_11.objectName()
  285.         value = str(self.settings.value(label_11name))
  286.         if value != "None":
  287.             self.label_11.setText(value)
  288.  
  289.         label_13name = self.label_13.objectName()
  290.         value = str(self.settings.value(label_13name))
  291.         if value != "None":
  292.             self.label_13.setText(value)
  293.  
  294.         lineEditname = self.lineEdit.objectName()
  295.         value = str(self.settings.value(lineEditname))
  296.         if value != "None":
  297.             self.lineEdit.setText(value)
  298.  
  299.         comboBoxname = self.comboBox.objectName()
  300.         value = str(self.settings.value(comboBoxname))
  301.         index = self.comboBox.findText(value, QtCore.Qt.MatchFixedString)
  302.         if index >= 0:
  303.             self.comboBox.setCurrentIndex(index)
  304.  
  305.     def start_changing(self):
  306.         emails1path = self.label_2.text()
  307.         emails2path = self.label_4.text()
  308.         useragentspath = self.label_11.text()
  309.         proxypath = self.label_13.text()
  310.         antigatekey = self.lineEdit.text()
  311.         proxytype = self.comboBox.currentText()
  312.  
  313.         if antigatekey == "" or antigatekey is None:
  314.             self.textBrowser.append("Введите ключ antigate.")
  315.             return
  316.  
  317.         if emails1path == "" or emails1path is None:
  318.             self.textBrowser.append("Введите emails #1.")
  319.             return
  320.  
  321.         if emails2path == "" or emails2path is None:
  322.             self.textBrowser.append("Введите emails #2.")
  323.             return
  324.  
  325.         if useragentspath == "" or useragentspath is None:
  326.             self.textBrowser.append("Введите useragents.")
  327.             return
  328.  
  329.         self.threads_changer = []
  330.         for i in range(1):
  331.             thread = Changer_email(emails1path, emails2path, useragentspath,
  332.                                    antigatekey, proxypath, proxytype)
  333.             thread.newdata.connect(self.add_new_data)
  334.             thread.started.connect(
  335.                 lambda: self.update_log(
  336.                     message=u"Работа начата."))
  337.             thread.finished.connect(
  338.                 lambda: self.update_log(
  339.                     message=u"Работа завершена."))
  340.             thread.exitsignal.connect(self.stop_changing)
  341.             thread.log_message.connect(self.update_log)
  342.             thread.balanceantigate.connect(self.update_ag_balance)
  343.             thread.statisticsantigate.connect(self.update_ag_load)
  344.             self.pushButton_4.clicked.connect(self.stop_changing)
  345.             self.pushButton_4.setEnabled(True)
  346.             self.pushButton_3.setEnabled(False)
  347.             thread.start()
  348.             self.threads_changer.append(thread)
  349.  
  350.     def stop_changing(self):
  351.         for thread in self.threads_changer:
  352.             try:
  353.                 thread.driver.quit()
  354.             except:
  355.                 pass
  356.             thread.terminate()
  357.         self.pushButton_3.setEnabled(True)
  358.         self.pushButton_4.setEnabled(False)
  359.  
  360.     def add_new_data(self, newdata):
  361.         self.textEdit.append(newdata)
  362.  
  363.     def update_log(self, message):
  364.         self.textBrowser_2.append(message)
  365.  
  366.     def update_ag_balance(self, balance):
  367.         self.label_7.setText('{0}$'.format(balance))
  368.  
  369.     def update_ag_load(self, load):
  370.         self.label_9.setText('{0}%'.format(load))
  371.  
  372.  
  373. class Emails1_List():
  374.     emlist1 = []
  375.  
  376.  
  377. class Emails2_List():
  378.     emlist2 = []
  379.  
  380.  
  381. class Proxy_List():
  382.     proxyls = []
  383.  
  384.  
  385. class Changer_email(QtCore.QThread):
  386.     newdata = QtCore.pyqtSignal(str)
  387.     exitsignal = QtCore.pyqtSignal()
  388.     log_message = QtCore.pyqtSignal(str)
  389.     balanceantigate = QtCore.pyqtSignal(str)
  390.     statisticsantigate = QtCore.pyqtSignal(str)
  391.  
  392.     def __init__(self, emails1path, emails2path, useragentspath,
  393.                  antigatekey, proxypath, proxytype, parent=None):
  394.         super(Changer_email, self).__init__(parent)
  395.         self._isRunning = True
  396.         self.emails1path = emails1path
  397.         self.emails2path = emails2path
  398.         self.useragentspath = useragentspath
  399.         self.proxypath = proxypath
  400.         self.antigatekey = antigatekey
  401.         self.proxytype = proxytype
  402.  
  403.     def stop(self):
  404.         self._isRunning = False
  405.  
  406.     def run(self):
  407.         emails1 = open(self.emails1path, "r").readlines()
  408.         emails2 = open(self.emails2path, "r").readlines()
  409.         useragents = open(self.useragentspath, "r").readlines()
  410.         try:
  411.             proxy1 = open(self.proxypath, "r").readlines()
  412.             noproxy = False
  413.         except:
  414.             noproxy = True
  415.  
  416.         for item in emails1:
  417.             if item != "":
  418.                 Emails1_List().emlist1.append(item)
  419.  
  420.         for item in emails2:
  421.             if item != "":
  422.                 Emails2_List().emlist2.append(item)
  423.  
  424.         if noproxy is False:
  425.             for item in proxy1:
  426.                 if item != "":
  427.                     Proxy_List().proxyls.append(item)
  428.  
  429.         startlogbadpr = True
  430.         while True:
  431.             resp = ""
  432.             start = True
  433.             print("STEP #1")
  434.             while resp != "Success_solve":
  435.                 DesiredCapabilities.PHANTOMJS[
  436.                     "phantomjs.page.settings.userAgent"] = random.choice(
  437.                         useragents)
  438.                 DesiredCapabilities.PHANTOMJS[
  439.                     'phantomjs.page.customHeaders.Accept-Language'] = 'en-US'
  440.  
  441.                 try:
  442.                     self.bigproxyauth = Proxy_List().proxyls.pop()
  443.                     if ";" in self.bigproxyauth:
  444.                         self.proxy = self.bigproxyauth.split(";")[0]
  445.                         self.userpass = self.bigproxyauth.split(";")[1]
  446.                     else:
  447.                         self.proxy = self.bigproxyauth
  448.                         self.userpass = ""
  449.                 except Exception as e:
  450.                     traceback.print_exc()
  451.                     if startlogbadpr is True:
  452.                         self.log_message.emit(
  453.                                 "Прокси закончились, работаю без прокси.")
  454.                         startlogbadpr = False
  455.                     else:
  456.                         pass
  457.                     self.proxy = ""
  458.                     self.userpass = ""
  459.  
  460.                 path = os.path.abspath(
  461.                     os.path.join(os.path.dirname(__file__), 'bin', 'driver'))
  462.                 self.driver = webdriver.PhantomJS(path, service_args=[
  463.                     '--ignore-ssl-errors=true',
  464.                     '--proxy=%s' % str(self.proxy),
  465.                     '--proxy-type=%s' % str(self.proxytype),
  466.                     '--proxy-auth=%s' % str(self.userpass)])
  467.                 self.driver.set_window_size(1280, 1024)
  468.                 self.driver.set_page_load_timeout(1)
  469.                 if start is True:
  470.                     try:
  471.                         bigemail1 = Emails1_List().emlist1.pop(0)
  472.                         bigemail2 = Emails2_List().emlist2.pop(0)
  473.                         if " |" in bigemail1:
  474.                             em1 = bigemail1.split(" |")[0]
  475.                         else:
  476.                             em1 = bigemail1
  477.                         email1 = em1.split(":")[0]
  478.                         password1 = em1.split(":")[1]
  479.                     except Exception as e:
  480.                         traceback.print_exc()
  481.                         self.log_message.emit(
  482.                             "Обработанны все записи, завершаю работу.")
  483.                         self.driver.quit()
  484.                         self.exitsignal.emit()
  485.                 try:
  486.                     resp = self.changer1(email1)
  487.                 except Exception as e:
  488.                     traceback.print_exc()
  489.                 if resp == "Bad captcha":
  490.                     self.driver.quit()
  491.                     start = False
  492.                 elif resp == "Bad email#1_not_reg":
  493.                     self.log_message.emit(
  494.                         "Данный email не связан с Instagram - {0}.".format(
  495.                             bigemail1.replace("\n", "")))
  496.                     Emails2_List().emlist2.insert(0, bigemail2)
  497.                     with open("not_reg_emails1.txt", "a") as ad_emails1:
  498.                         ad_emails1.write(bigemail1.replace("\n", "") + "\n")
  499.                     with open(self.emails1path, "r") as f:
  500.                         lines = f.readlines()
  501.                     with open(self.emails1path, "w") as f1:
  502.                         for line in lines:
  503.                             if line != bigemail1.replace("\n", "") + "\n" and line != bigemail1.replace("\n", ""):
  504.                                 f1.write(line)
  505.                     start = True
  506.                     self.driver.quit()
  507.                 elif resp == "Bad email#1_not_valid":
  508.                     self.log_message.emit(
  509.                         "Email невалидный - {0}.".format(bigemail1.replace("\n", "")))
  510.                     Emails2_List().emlist2.insert(0, bigemail2)
  511.                     with open("not_valid_emails1.txt", "a") as ad_emails1:
  512.                         ad_emails1.write(bigemail1.replace("\n", "") + "\n")
  513.                     with open(self.emails1path, "r") as f:
  514.                         lines = f.readlines()
  515.                     with open(self.emails1path, "w") as f1:
  516.                         for line in lines:
  517.                             if line != bigemail1.replace("\n", "") + "\n" and line != bigemail1.replace("\n", ""):
  518.                                 f1.write(line)
  519.                     start = True
  520.                     self.driver.quit()
  521.                 elif resp == "Too many req":
  522.                     time.sleep(5)
  523.                     start = False
  524.                     self.driver.quit()
  525.                 elif resp == "Bad proxy":
  526.                     try:
  527.                         self.bigproxyauth = Proxy_List().proxyls.pop()
  528.                         if ";" in self.bigproxyauth:
  529.                             self.proxy = self.bigproxyauth.split(";")[0]
  530.                             self.userpass = self.bigproxyauth.split(";")[1]
  531.                         else:
  532.                             self.proxy = self.bigproxyauth
  533.                             self.userpass = ""
  534.                     except:
  535.                         if startlogbadpr is True:
  536.                             self.log_message.emit(
  537.                                     "Прокси закончились, работаю без прокси.")
  538.                             startlogbadpr = False
  539.                         else:
  540.                             pass
  541.                         self.proxy = ""
  542.                         self.userpass = ""
  543.                     self.driver.quit()
  544.  
  545.             print("STEP #2")
  546.             while True:
  547.                 try:
  548.                     resp = self.changer2(email1, password1)
  549.                 except Exception as e:
  550.                     traceback.print_exc()
  551.                 if resp == "Bad host":
  552.                     self.log_message.emit(
  553.                         "Настройки IMAP4 для данного email не валидны - {0}.".format(bigemail1.replace("\n", "")))
  554.                     url = ""
  555.                     start = False
  556.                     self.driver.quit()
  557.                     break
  558.                 elif resp == "Bad auth email#1":
  559.                     self.log_message.emit(
  560.                         "Не удалось войти в почту с указанными логин \ пароль - {0} Error№1.".format(bigemail1.replace("\n", "")))
  561.                     with open("bad_auth_email1.txt", "a") as ad_emails1:
  562.                         ad_emails1.write(bigemail1.replace("\n", "") + "\n")
  563.                     url = ""
  564.                     with open(self.emails1path, "r") as f:
  565.                         lines = f.readlines()
  566.                     with open(self.emails1path, "w") as f1:
  567.                         for line in lines:
  568.                             if line != bigemail1.replace("\n", "") + "\n" and line != bigemail1.replace("\n", ""):
  569.                                 f1.write(line)
  570.                     start = False
  571.                     url = ""
  572.                     self.driver.quit()
  573.                     break
  574.                 elif resp == "Bad search":
  575.                     with open(self.emails1path, "r") as f:
  576.                         lines = f.readlines()
  577.                     with open(self.emails1path, "w") as f1:
  578.                         for line in lines:
  579.                             if line != bigemail1.replace("\n", "") + "\n" and line != bigemail1.replace("\n", ""):
  580.                                 f1.write(line)
  581.                     url = ""
  582.                     start = False
  583.                     try:
  584.                         bigemail1 = Emails1_List().emlist1.pop(0)
  585.                         if " |" in bigemail1:
  586.                             em1 = bigemail1.split(" |")[0]
  587.                         else:
  588.                             em1 = bigemail1
  589.                         email1 = em1.split(":")[0]
  590.                         password1 = em1.split(":")[1]
  591.                         self.driver.quit()
  592.                     except:
  593.                         self.log_message.emit(
  594.                             "Обработанны все записи, завершаю работу.")
  595.                         self.driver.quit()
  596.                         self.exitsignal.emit()
  597.                     break
  598.                 elif "Success" in resp:
  599.                     url = resp.split("|")[1]
  600.                     username = resp.split("|")[2]
  601.                     newpassword = self.changer3(url)
  602.                     if newpassword == "Invalid link":
  603.                         pass
  604.                     else:
  605.                         break
  606.  
  607.             if url != "":
  608.                 print("STEP #3")
  609.                 self.changer4(username, newpassword)
  610.                 print("STEP #4")
  611.                 while True:
  612.                     resp = self.changer5(bigemail2)
  613.  
  614.                     if resp == "Email in use#1":
  615.                         self.log_message.emit(
  616.                             "Данный email уже используется - {0}.".format(bigemail2.replace("\n", "")))
  617.                         with open(self.emails2path, "r") as f:
  618.                             lines = f.readlines()
  619.                         with open(self.emails2path, "w") as f1:
  620.                             for line in lines:
  621.                                 if line != bigemail2.replace("\n", "") + "\n" and line != bigemail1.replace("\n", ""):
  622.                                     f1.write(line)
  623.                         try:
  624.                             bigemail2 = Emails2_List().emlist2.pop(0)
  625.                         except:
  626.                             self.log_message.emit(
  627.                                 "Обработанны все записи, завершаю работу.")
  628.                             self.driver.quit()
  629.                             self.exitsignal.emit()
  630.                     elif resp == "Bad host":
  631.                         self.log_message.emit(
  632.                             "Настройки IMAP4 для данного email не валидны - {0}.".format(bigemail2.replace("\n", "")))
  633.                         try:
  634.                             bigemail2 = Emails2_List().emlist2.pop(0)
  635.                         except:
  636.                             self.log_message.emit(
  637.                                 "Обработанны все записи, завершаю работу.")
  638.                             self.driver.quit()
  639.                             self.exitsignal.emit()
  640.                     elif resp == "Bad auth email#2":
  641.                         print("Bad auth email#2")
  642.                         # Emails1_List().emlist2.insert(0, bigemail1)
  643.                         with open(self.emails2path, "r") as f:
  644.                             lines = f.readlines()
  645.                         with open(self.emails2path, "w") as f1:
  646.                             for line in lines:
  647.                                 if line != bigemail2.replace("\n", "") + "\n" and line != bigemail1.replace("\n", ""):
  648.                                     f1.write(line)
  649.                         self.log_message.emit(
  650.                             "Не удалось войти в почту с указанными логин \ пароль - {0} Error№2.".format(bigemail2.replace("\n", "")))
  651.                         with open("bad_auth_email2.txt", "a") as ad_emails1:
  652.                             ad_emails1.write(
  653.                                 bigemail2.replace("\n", "") + "\n")
  654.                         try:
  655.                             bigemail2 = Emails2_List().emlist2.pop(0)
  656.                         except:
  657.                             self.log_message.emit(
  658.                                 "Обработанны все записи, завершаю работу.")
  659.                             self.driver.quit()
  660.                             self.exitsignal.emit()
  661.                     elif resp == "Bad search":
  662.                         with open(self.emails2path, "r") as f:
  663.                             lines = f.readlines()
  664.                         with open(self.emails2path, "w") as f1:
  665.                             for line in lines:
  666.                                 if line != bigemail2.replace("\n", "") + "\n" and line != bigemail1.replace("\n", ""):
  667.                                     f1.write(line)
  668.                         try:
  669.                             bigemail2 = Emails2_List().emlist2.pop(0)
  670.                         except:
  671.                             self.log_message.emit(
  672.                                 "Обработанны все записи, завершаю работу.")
  673.                             self.driver.quit()
  674.                             self.exitsignal.emit()
  675.                     elif resp == "Block by istagram":
  676.                         start = True
  677.                         break
  678.                     elif resp == "Success":
  679.                         if " |" in bigemail2:
  680.                             em2 = bigemail2.split(" |")[0]
  681.                         else:
  682.                             em2 = bigemail2
  683.                         email2 = em2.split(":")[0]
  684.                         password2 = em2.split(":")[1]
  685.                         self.newdata.emit(
  686.                             username.replace("\n", "") + ":" + newpassword.replace("\n", "") + ":" + email2.replace("\n", "") + ":" + password2.replace("\n", ""))
  687.                         with open(self.emails1path, "r") as f:
  688.                             lines = f.readlines()
  689.                         with open(self.emails1path, "w") as f1:
  690.                             for line in lines:
  691.                                 if line != bigemail1.replace("\n", "") + "\n" and line != bigemail1.replace("\n", ""):
  692.                                     f1.write(line)
  693.                         with open(self.emails2path, "r") as f:
  694.                             lines = f.readlines()
  695.                         with open(self.emails2path, "w") as f1:
  696.                             for line in lines:
  697.                                 if line != bigemail2.replace("\n", "") + "\n" and line != bigemail1.replace("\n", ""):
  698.                                     f1.write(line)
  699.                         start = True
  700.                         Proxy_List().proxyls.append(self.bigproxyauth)
  701.                         break
  702.             self.driver.quit()
  703.  
  704.     def changer1(self, email1):
  705.         self.driver.delete_all_cookies()
  706.         try:
  707.             self.driver.get(
  708.                 "https://www.instagram.com/accounts/password/reset/")
  709.         except:
  710.             pass
  711.  
  712.         try:
  713.             WebDriverWait(self.driver, 25).until(
  714.                 EC.visibility_of_element_located(
  715.                     (By.XPATH,
  716.                         "//*[@id='recaptcha_challenge_image']")))
  717.         except:
  718.             self.log_message.emit("Неполадки с соединением, нет связи или плохой прокси.")
  719.             self.driver.quit()
  720.             return "Bad proxy"
  721.  
  722.         self.driver.find_element(By.XPATH,
  723.                                  "//*[@id='id_email_or_username']").clear()
  724.         self.driver.find_element(By.XPATH,
  725.                                  "//*[@id='id_email_or_username']").send_keys(
  726.             email1)
  727.  
  728.         element = self.driver.find_element(By.XPATH,
  729.                                            "//*[@id='recaptcha_challenge_image']")
  730.         location = element.location
  731.         size = element.size
  732.  
  733.         self.driver.save_screenshot('captches/temporary_captcha.png')
  734.  
  735.         im = Image.open('captches/temporary_captcha.png')
  736.  
  737.         left = int(location['x'])
  738.         top = location['y']
  739.         right = int(location['x']) + size['width']
  740.         bottom = location['y'] + size['height']
  741.  
  742.         im = im.crop((left, top, right, bottom))
  743.  
  744.         captcha1 = "captches/captcha_" + str(uuid.uuid4()) + ".png"
  745.  
  746.         captcha = captcha1.replace("-", "")
  747.  
  748.         im.save(captcha)
  749.  
  750.         a = Antigate(self.antigatekey)
  751.         a.params = {'is_russian': '1'}
  752.         balance = a.balance()
  753.         self.balanceantigate.emit(str(balance))
  754.         load = a.load()
  755.         self.statisticsantigate.emit(load)
  756.  
  757.         solvedcaptcha = ""
  758.  
  759.         while solvedcaptcha != "ERROR_NO_SLOT_AVAILABLE":
  760.             captcha2 = a.capcha(captcha)
  761.             solvedcaptcha = "{0}".format(captcha2)
  762.             if len(str(captcha2)) < 2:
  763.                 captcha2.bad()
  764.                 print("CALL BAD CAPTCHA")
  765.             elif solvedcaptcha == "ERROR_NO_SLOT_AVAILABLE":
  766.                 self.log_message.emit(
  767.                     "Сервис антигейт перегружен(ERROR_NO_SLOT_AVAILABLE), жду 3 секунды...")
  768.                 time.sleep(3)
  769.             elif solvedcaptcha == "ERROR_ZERO_BALANCE":
  770.                 self.log_message.emit(
  771.                     "Нулевой баланс на антигейт, выход.")
  772.                 self.driver.quit()
  773.                 self.exitsignal.emit()
  774.             elif solvedcaptcha == "ERROR_CAPTCHA_UNSOLVABLE":
  775.                 return "Bad captcha"
  776.             else:
  777.                 break
  778.  
  779.         print('Capcha text: {0}'.format(solvedcaptcha))
  780.  
  781.         self.driver.find_element(By.XPATH,
  782.                                  "//*[@id='recaptcha_response_field']").clear()
  783.         self.driver.find_element(By.XPATH,
  784.                                  "//*[@id='recaptcha_response_field']").send_keys(
  785.                                  solvedcaptcha)
  786.  
  787.         self.driver.find_element_by_xpath(
  788.             '//input[@type="submit"]').send_keys(Keys.ENTER)
  789.  
  790.         count = 0
  791.         while True:
  792.             try:
  793.                 self.driver.find_element(By.XPATH,
  794.                                          "//p[contains(text(), 'Thanks! Please check')]")
  795.                 os.remove(captcha)
  796.                 return "Success_solve"
  797.             except Exception as e:
  798.                 # traceback.print_exc()
  799.                 print("0")
  800.             try:
  801.                 self.driver.find_element(By.XPATH,
  802.                                          u"//p[contains(text(),'captcha solution was not correct')]")
  803.                 captcha2.bad()
  804.                 print("Bad captcha")
  805.                 os.remove(captcha)
  806.                 return "Bad captcha"
  807.             except Exception as e:
  808.                 print("1")
  809.             try:
  810.                 self.driver.find_element(By.XPATH,
  811.                                          '''//p[contains(text(),"doesn't have an associated user account")]''')
  812.                 os.remove(captcha)
  813.                 return "Bad email#1_not_reg"
  814.             except Exception as e:
  815.                 print("2")
  816.             try:
  817.                 self.driver.find_element(By.XPATH,
  818.                                          "//p[contains(text(), 'Sorry, this user is not active')]")
  819.                 os.remove(captcha)
  820.                 return "Bad email#1_not_valid"
  821.             except Exception as e:
  822.                 print("3")
  823.             time.sleep(1)
  824.             self.driver.save_screenshot("test1.png")
  825.             count += 1
  826.             if count > 12:
  827.                 os.remove(captcha)
  828.                 return "Too many req"
  829.  
  830.     def changer2(self, email1, password1):
  831.         host1 = email1.split("@")[1]
  832.         with open("hosts.txt", "r") as hosts:
  833.             hosts = hosts.readlines()
  834.             for host in hosts:
  835.                 if host1.replace("\n", "") in host:
  836.                     break
  837.         while True:
  838.             try:
  839.                 mail = imaplib.IMAP4_SSL(host.replace("\n", ""))
  840.             except Exception as e:
  841.                 traceback.print_exc()
  842.                 return "Bad host"
  843.             try:
  844.                 print(email1.replace("\n", "") + "1")
  845.                 print(password1.replace("\n", "") + "1")
  846.                 mail.login(
  847.                     email1.replace("\n", ""), password1.replace("\n", ""))
  848.             except Exception as e:
  849.                 traceback.print_exc()
  850.                 return "Bad auth email#1"
  851.  
  852.             mail.select('inbox')
  853.             try:
  854.                 status, messages = mail.search(None, '(UNSEEN)')
  855.             except:
  856.                 return "Bad search"
  857.             try:
  858.                 ids = messages[0]
  859.                 id_list = ids.split()
  860.  
  861.                 latest_email_id = id_list[-1]
  862.                 print(latest_email_id.decode("UTF-8"))
  863.                 result, data = mail.fetch(latest_email_id.decode("UTF-8"), "(RFC822)")
  864.  
  865.                 raw_email1 = data[0][1]
  866.                 raw_email = quopri.decodestring(raw_email1.decode("UTF-8"))
  867.                 msg = email.message_from_bytes(raw_email)
  868.  
  869.                 if msg.is_multipart():
  870.                     for payload in msg.get_payload():
  871.                         mess = payload.get_payload()
  872.                 else:
  873.                     mess = msg.get_payload()
  874.  
  875.                 urls = re.findall(
  876.                     'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', mess)
  877.  
  878.                 assert "instagram" in urls[2]
  879.                 assert "instagram" in urls[1]
  880.                 print(urls[2])
  881.                 acc1 = urls[1]
  882.                 username = acc1.split("/")[3]
  883.                 print(username)
  884.                 break
  885.             except Exception as e:
  886.                 mail.close()
  887.                 mail.logout()
  888.                 traceback.print_exc()
  889.                 time.sleep(1)
  890.             try:
  891.                 mail.logout()
  892.             except:
  893.                 pass
  894.  
  895.         return "Success" + "|" + urls[2] + "|" + username
  896.  
  897.     def changer3(self, url):
  898.         try:
  899.             self.driver.get(url)
  900.         except:
  901.             pass
  902.         try:
  903.             WebDriverWait(self.driver, 25).until(
  904.                 EC.visibility_of_element_located((By.XPATH,
  905.                                                   "//*[@id='id_new_password1']")))
  906.         except Exception as e:
  907.             print("Invalid link")
  908.             self.driver.save_screenshot("test5.png")
  909.             traceback.print_exc()
  910.             return "Invalid link"
  911.  
  912.         newpassword = ''.join(
  913.             random.choice(
  914.                 string.ascii_uppercase + string.digits) for _ in range(8))
  915.  
  916.         self.driver.find_element(By.XPATH,
  917.                                  "//*[@id='id_new_password1']").clear()
  918.         self.driver.find_element(By.XPATH,
  919.                                  "//*[@id='id_new_password1']").send_keys(
  920.                                  newpassword)
  921.  
  922.         self.driver.find_element(By.XPATH,
  923.                                  "//*[@id='id_new_password2']").clear()
  924.         self.driver.find_element(By.XPATH,
  925.                                  "//*[@id='id_new_password2']").send_keys(
  926.                                  newpassword)
  927.  
  928.         self.driver.find_element_by_xpath(
  929.             "//input[@type='submit']").send_keys(Keys.ENTER)
  930.  
  931.         try:
  932.             WebDriverWait(self.driver, 40).until(
  933.                 EC.visibility_of_element_located(
  934.                     (By.XPATH, "//button[contains(text(),'Log in')]")))
  935.         except Exception as e:
  936.             traceback.print_exc()
  937.             self.driver.save_screenshot("test2.png")
  938.             self.log_message.emit("Неполадки с соединением, нет связи.")
  939.             self.driver.quit()
  940.             self.exitsignal.emit()
  941.  
  942.         return newpassword
  943.  
  944.     def changer4(self, username, newpassword):
  945.         self.driver.save_screenshot("test4.png")
  946.         try:
  947.             self.driver.get("https://www.instagram.com/accounts/login/")
  948.         except:
  949.             pass
  950.         a = False
  951.         try:
  952.             self.driver.find_element(By.XPATH,
  953.                                  "//input[@placeholder='Search']")
  954.             a = True
  955.         except:
  956.             pass
  957.         if a is False:
  958.             try:
  959.                 WebDriverWait(self.driver, 40).until(
  960.                     EC.visibility_of_element_located(
  961.                         (By.XPATH, "//button[contains(text(),'Log in')]")))
  962.             except Exception as e:
  963.                 traceback.print_exc()
  964.                 self.driver.save_screenshot("test9.png")
  965.                 self.log_message.emit("Неполадки с соединением, нет связи.")
  966.                 self.driver.quit()
  967.                 self.exitsignal.emit()
  968.             self.driver.find_element(By.XPATH,
  969.                                      "//input[@placeholder='Username']").clear()
  970.             self.driver.find_element(By.XPATH,
  971.                                      "//input[@placeholder='Username']").send_keys(
  972.                 username)
  973.  
  974.             self.driver.find_element(By.XPATH,
  975.                                      "//input[@placeholder='Password']").clear()
  976.             self.driver.find_element(By.XPATH,
  977.                                      "//input[@placeholder='Password']").send_keys(
  978.                 newpassword)
  979.  
  980.             print(newpassword)
  981.  
  982.             self.driver.find_element_by_xpath(
  983.                 "//button[contains(text(),'Log in')]").send_keys(Keys.ENTER)
  984.  
  985.             while True:
  986.                 try:
  987.                     self.driver.find_element_by_xpath(
  988.                         "//input[@placeholder='Search']")
  989.                     break
  990.                 except:
  991.                     pass
  992.                 try:
  993.                     self.driver.find_element(By.XPATH,
  994.                                          "//input[@name='approve']").send_keys(Keys.ENTER)
  995.                     WebDriverWait(self.driver, 25).until(
  996.                         EC.visibility_of_element_located((By.XPATH,
  997.                                                       "//input[@name='OK']")))
  998.                     self.driver.find_element(By.XPATH,
  999.                                          "//input[@name='OK']").send_keys(Keys.ENTER)
  1000.                     WebDriverWait(self.driver, 25).until(
  1001.                         EC.visibility_of_element_located((By.XPATH,
  1002.                                                       "//input[@placeholder='Search']")))
  1003.                     try:
  1004.                         self.driver.get("https://www.instagram.com/accounts/edit/")
  1005.                     except:
  1006.                         pass
  1007.                     break
  1008.                 except:
  1009.                     pass
  1010.  
  1011.                 self.driver.save_screenshot("test3.png")
  1012.  
  1013.     def changer5(self, bigemail2):
  1014.         if " |" in bigemail2:
  1015.             em2 = bigemail2.split(" |")[0]
  1016.         else:
  1017.             em2 = bigemail2
  1018.         email2 = em2.split(":")[0]
  1019.         password2 = em2.split(":")[1]
  1020.         print(email2)
  1021.         print(password2)
  1022.         try:
  1023.             self.driver.get("https://www.instagram.com/accounts/edit/")
  1024.         except:
  1025.             pass
  1026.  
  1027.         while True:
  1028.             try:
  1029.                 self.driver.find_element(
  1030.                     By.XPATH, "//input[@placeholder='Search']")
  1031.                 break
  1032.             except:
  1033.                 pass
  1034.             try:
  1035.                 self.driver.find_element(By.XPATH, "//*[@id='email']")
  1036.                 break
  1037.             except:
  1038.                 pass
  1039.             try:
  1040.                 self.driver.find_element(By.XPATH,
  1041.                                      "//input[@name='approve']").send_keys(Keys.ENTER)
  1042.                 WebDriverWait(self.driver, 25).until(
  1043.                     EC.visibility_of_element_located((By.XPATH,
  1044.                                                   "//input[@name='OK']")))
  1045.                 self.driver.find_element(By.XPATH,
  1046.                                      "//input[@name='OK']").send_keys(Keys.ENTER)
  1047.                 WebDriverWait(self.driver, 25).until(
  1048.                     EC.visibility_of_element_located((By.XPATH,
  1049.                                                   "//input[@placeholder='Search']")))
  1050.                 try:
  1051.                     self.driver.get("https://www.instagram.com/accounts/edit/")
  1052.                 except:
  1053.                     pass
  1054.                 break
  1055.             except:
  1056.                 pass
  1057.             self.driver.save_screenshot("test8.png")
  1058.             print("test8")
  1059.         try:
  1060.             self.driver.get("https://www.instagram.com/accounts/edit/")
  1061.         except:
  1062.             pass
  1063.         try:
  1064.             WebDriverWait(self.driver, 25).until(
  1065.                 EC.visibility_of_element_located((By.XPATH,
  1066.                                                   "//*[@id='email']")))
  1067.         except Exception as e:
  1068.             self.driver.save_screenshot("test6.png")
  1069.             traceback.print_exc()
  1070.             self.log_message.emit("Неполадки с соединением, нет связи.")
  1071.             self.driver.quit()
  1072.             self.exitsignal.emit()
  1073.  
  1074.         self.driver.find_element(By.XPATH,
  1075.                                  "//*[@id='email']").clear()
  1076.         self.driver.find_element(By.XPATH,
  1077.                                  "//*[@id='email']").send_keys(email2)
  1078.  
  1079.         self.driver.find_element_by_xpath(
  1080.             "//input[@type='submit']").send_keys(Keys.ENTER)
  1081.  
  1082.         while True:
  1083.             try:
  1084.                 self.driver.find_element(By.XPATH,
  1085.                                      "//p[contains(text(), 'Successfully updated your profile')]")
  1086.                 break
  1087.             except:
  1088.                 pass
  1089.             try:
  1090.                 self.driver.find_element(By.XPATH,
  1091.                                      "//p[@class='alert-red'][1]")
  1092.                 return "Email in use#1"
  1093.             except:
  1094.                 pass
  1095.             try:
  1096.                
  1097.                 self.driver.find_element(By.XPATH, "//div[@id='checkpoint']")
  1098.                 return "Block by istagram"
  1099.             except:
  1100.                 pass
  1101.             self.driver.save_screenshot("test5.png")
  1102.  
  1103.         while True:
  1104.             host1 = email2.split("@")[1]
  1105.             with open("hosts.txt", "r") as hosts:
  1106.                 hosts = hosts.readlines()
  1107.                 for host in hosts:
  1108.                     if host1.replace("\n", "") in host:
  1109.                         print(host)
  1110.                         break
  1111.  
  1112.             try:
  1113.                 print(host.replace("\n", ""))
  1114.                 print(email2.replace("\n", ""))
  1115.                 print(password2.replace("\n", ""))
  1116.                 mail = imaplib.IMAP4_SSL(host.replace("\n", ""))
  1117.             except:
  1118.                 return "Bad host"
  1119.  
  1120.             try:
  1121.                 mail.login(email2.replace("\n", ""), password2.replace("\n", ""))
  1122.             except:
  1123.                 print("Bad auth email#2")
  1124.                 return "Bad auth email#2"
  1125.             mail.select('inbox')
  1126.  
  1127.             try:
  1128.                 status, messages = mail.search(None, '(UNSEEN)')
  1129.             except:
  1130.                 return "Bad search"
  1131.             try:
  1132.                 ids = messages[0]
  1133.                 print(ids)
  1134.                 id_list = ids.split()
  1135.                 latest_email_id = id_list[-1]
  1136.  
  1137.                 result, data = mail.fetch(latest_email_id, "(RFC822)")
  1138.  
  1139.                 raw_email1 = data[0][1]
  1140.                 raw_email = quopri.decodestring(raw_email1)
  1141.                 msg = email.message_from_bytes(raw_email)
  1142.  
  1143.                 if msg.is_multipart():
  1144.                     for payload in msg.get_payload():
  1145.                         mess = payload.get_payload()
  1146.                 else:
  1147.                     mess = msg.get_payload()
  1148.  
  1149.                 urls = re.findall(
  1150.                     'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', mess)
  1151.  
  1152.                 assert "instagram" in urls[2]
  1153.                 assert "instagram" in urls[1]
  1154.                 print(urls[2])
  1155.                 url = urls[2]
  1156.                 mail.close()
  1157.                 mail.logout()
  1158.                 break
  1159.             except Exception as e:
  1160.  
  1161.                 traceback.print_exc()
  1162.                 time.sleep(1)
  1163.  
  1164.         try:
  1165.             self.driver.get(url)
  1166.         except:
  1167.             pass
  1168.  
  1169.         try:
  1170.             WebDriverWait(self.driver, 25).until(
  1171.                 EC.visibility_of_element_located(
  1172.                     (By.XPATH, "//p[contains(text(), 'confirmed your email')]")))
  1173.         except:
  1174.             traceback.print_exc()
  1175.             self.log_message.emit("Неполадки с соединением, нет связи.")
  1176.             self.driver.quit()
  1177.             self.exitsignal.emit()
  1178.  
  1179.         return "Success"
  1180.  
  1181.  
  1182. class Antigate():
  1183.  
  1184.     def __init__(self, key, params={}):
  1185.         self.key = key
  1186.         self.params = params
  1187.  
  1188.     def capcha(self, path):
  1189.         data = {
  1190.             'method': 'post',
  1191.             'key': self.key
  1192.         }
  1193.         data.update(self.params)
  1194.         files = {'file': open(path, 'rb')}
  1195.  
  1196.         response = http.post('http://antigate.com/in.php',
  1197.                              data, files=files).text
  1198.  
  1199.         if 'OK' in response:
  1200.             capcha_id = response.split('|')[1]
  1201.         else:
  1202.             return response
  1203.  
  1204.         text = self.check(capcha_id)
  1205.  
  1206.         return Antigate_Capcha(text, capcha_id, self.key)
  1207.  
  1208.     def check(self, capcha_id):
  1209.         data = {
  1210.             'action': 'get',
  1211.             'key': self.key,
  1212.             'id': capcha_id
  1213.         }
  1214.  
  1215.         while True:
  1216.             time.sleep(1)
  1217.             response = http.post('http://antigate.com/res.php', data).text
  1218.  
  1219.             if 'OK' in response:
  1220.                 return response.split('|')[1]
  1221.  
  1222.             elif 'ERROR' in response:
  1223.                 return response
  1224.  
  1225.     def balance(self):
  1226.         data = {
  1227.             'action': 'getbalance',
  1228.             'key': self.key
  1229.         }
  1230.  
  1231.         response = http.post('http://antigate.com/res.php', data).text
  1232.  
  1233.         if 'ERROR' not in response:
  1234.             return float(response)
  1235.         else:
  1236.             return response
  1237.  
  1238.     def load(self):
  1239.         data = urllib2.urlopen('http://antigate.com/load.php').read()
  1240.  
  1241.         return XML(data).find("load").text
  1242.  
  1243.  
  1244. class Antigate_Capcha():
  1245.  
  1246.     def __init__(self, text, capcha_id, key):
  1247.         self.text = text
  1248.         self.capcha_id = capcha_id
  1249.         self.key = key
  1250.  
  1251.     def __str__(self):
  1252.         return str(self.text)
  1253.  
  1254.     def __repr__(self):
  1255.         return self.text
  1256.  
  1257.     def bad(self):
  1258.         data = {
  1259.             'action': 'reportbad',
  1260.             'key': self.key,
  1261.             'id': self.capcha_id
  1262.         }
  1263.  
  1264.         response = http.post('http://antigate.com/res.php', data).text
  1265.  
  1266.         if 'OK' in response:
  1267.             return True
  1268.         else:
  1269.             return response
  1270.  
  1271.  
  1272. if __name__ == '__main__':
  1273.     try:
  1274.         os.system('taskkill /im driver.exe /f')
  1275.     except:
  1276.         pass
  1277.     app = QtGui.QApplication(sys.argv)
  1278.     app.setStyle('windowsvista')
  1279.     w = Program()
  1280.     w.show()
  1281.     app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement