Skip to content

Instantly share code, notes, and snippets.

@tbhaxor
Created Mar 25, 2020
Embed
What would you like to do?
from PyQt5 import QtWidgets, QtCore
from ui import Ui_MainWindow
from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.chrome.options import Options
import os
import traceback
import pickle as pkl
from pathlib import Path
from typing import List, Dict, Union
class Application(Ui_MainWindow):
def __init__(self,
window: QtWidgets.QMainWindow,
driver: WebDriver = None):
self.parent = window
self.driver = driver
self.setupUi(window)
self.retranslateUi(window)
qtRectangle = window.frameGeometry()
centerPoint = QtWidgets.QDesktopWidget().availableGeometry().center()
qtRectangle.moveCenter(centerPoint)
window.move(qtRectangle.topLeft())
self.__makeHandlers()
self.file = os.path.join(Path.home(), "_linkedin.db")
self.db: Dict[str, str] = {
"api": "",
"email": "",
"password": "",
"sent": [],
"delay": 10,
"template": ""
}
self.search_limit.valueChanged.connect(print)
pass
def __makeHandlers(self):
self.search_limit.valueChanged.connect(print)
pass
def handle_fetch(self):
pass
def __login(self):
driver.get("https://www.linkedin.com/login")
# /html/body/div[1]/main/div/form/div[1]/input
# /html/body/div[1]/main/div/form/div[2]/input
# /html/body/div[1]/main/div/form/div[4]/button
pass
pass
if __name__ == "__main__":
import sys
try:
opts = Options()
opts.headless = os.environ.get("PYDBG", "0") != "1"
driver: WebDriver = WebDriver(options=opts)
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Application(MainWindow)
ui.setupUi(MainWindow)
MainWindow.show()
app.exec_()
pass
except Exception:
print(traceback.format_exc())
pass
finally:
driver.quit()
pass
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'recent.ui'
#
# Created by: PyQt5 UI code generator 5.14.0
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setWindowModality(QtCore.Qt.ApplicationModal)
MainWindow.setEnabled(True)
MainWindow.resize(975, 600)
MainWindow.setMinimumSize(QtCore.QSize(975, 600))
MainWindow.setMaximumSize(QtCore.QSize(975, 600))
MainWindow.setMouseTracking(False)
MainWindow.setFocusPolicy(QtCore.Qt.NoFocus)
MainWindow.setAutoFillBackground(False)
MainWindow.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
MainWindow.setTabShape(QtWidgets.QTabWidget.Rounded)
MainWindow.setUnifiedTitleAndToolBarOnMac(True)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
self.tabWidget.setGeometry(QtCore.QRect(-3, 0, 981, 611))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth())
self.tabWidget.setSizePolicy(sizePolicy)
self.tabWidget.setObjectName("tabWidget")
self.t_msngr = QtWidgets.QWidget()
self.t_msngr.setObjectName("t_msngr")
self.label_4 = QtWidgets.QLabel(self.t_msngr)
self.label_4.setGeometry(QtCore.QRect(10, 540, 510, 17))
self.label_4.setObjectName("label_4")
self.widget = QtWidgets.QWidget(self.t_msngr)
self.widget.setGeometry(QtCore.QRect(13, 10, 951, 194))
self.widget.setObjectName("widget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(self.widget)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.txt_recent_profiles = QtWidgets.QPlainTextEdit(self.widget)
self.txt_recent_profiles.setReadOnly(True)
self.txt_recent_profiles.setObjectName("txt_recent_profiles")
self.horizontalLayout.addWidget(self.txt_recent_profiles)
self.widget1 = QtWidgets.QWidget(self.t_msngr)
self.widget1.setGeometry(QtCore.QRect(581, 530, 381, 31))
self.widget1.setObjectName("widget1")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.widget1)
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.btn_fetch = QtWidgets.QPushButton(self.widget1)
self.btn_fetch.setObjectName("btn_fetch")
self.horizontalLayout_2.addWidget(self.btn_fetch)
self.btn_save_template = QtWidgets.QPushButton(self.widget1)
self.btn_save_template.setObjectName("btn_save_template")
self.horizontalLayout_2.addWidget(self.btn_save_template)
self.btn_send_all = QtWidgets.QPushButton(self.widget1)
self.btn_send_all.setObjectName("btn_send_all")
self.horizontalLayout_2.addWidget(self.btn_send_all)
self.widget2 = QtWidgets.QWidget(self.t_msngr)
self.widget2.setGeometry(QtCore.QRect(120, 220, 841, 30))
self.widget2.setObjectName("widget2")
self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.widget2)
self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.label_2 = QtWidgets.QLabel(self.widget2)
self.label_2.setObjectName("label_2")
self.horizontalLayout_3.addWidget(self.label_2)
self.search_predicate = QtWidgets.QComboBox(self.widget2)
self.search_predicate.setObjectName("search_predicate")
self.search_predicate.addItem("")
self.search_predicate.addItem("")
self.search_predicate.addItem("")
self.search_predicate.addItem("")
self.horizontalLayout_3.addWidget(self.search_predicate)
self.horizontalLayout_5.addLayout(self.horizontalLayout_3)
spacerItem = QtWidgets.QSpacerItem(150, 20, QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_5.addItem(spacerItem)
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.searchee = QtWidgets.QLabel(self.widget2)
self.searchee.setObjectName("searchee")
self.horizontalLayout_4.addWidget(self.searchee)
self.search_limit = QtWidgets.QSpinBox(self.widget2)
self.search_limit.setObjectName("search_limit")
self.horizontalLayout_4.addWidget(self.search_limit)
self.horizontalLayout_5.addLayout(self.horizontalLayout_4)
self.widget3 = QtWidgets.QWidget(self.t_msngr)
self.widget3.setGeometry(QtCore.QRect(10, 270, 950, 241))
self.widget3.setObjectName("widget3")
self.verticalLayout = QtWidgets.QVBoxLayout(self.widget3)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setObjectName("verticalLayout")
self.label_3 = QtWidgets.QLabel(self.widget3)
self.label_3.setObjectName("label_3")
self.verticalLayout.addWidget(self.label_3)
self.txt_template = QtWidgets.QPlainTextEdit(self.widget3)
self.txt_template.setReadOnly(True)
self.txt_template.setObjectName("txt_template")
self.verticalLayout.addWidget(self.txt_template)
self.tabWidget.addTab(self.t_msngr, "")
self.t_stngs = QtWidgets.QWidget()
self.t_stngs.setObjectName("t_stngs")
self.btn_save_settings = QtWidgets.QPushButton(self.t_stngs)
self.btn_save_settings.setGeometry(QtCore.QRect(880, 540, 83, 25))
self.btn_save_settings.setObjectName("btn_save_settings")
self.widget4 = QtWidgets.QWidget(self.t_stngs)
self.widget4.setGeometry(QtCore.QRect(10, 20, 960, 81))
self.widget4.setObjectName("widget4")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.widget4)
self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.horizontalLayout_6 = QtWidgets.QHBoxLayout()
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.label_5 = QtWidgets.QLabel(self.widget4)
self.label_5.setObjectName("label_5")
self.horizontalLayout_6.addWidget(self.label_5)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_6.addItem(spacerItem1)
self.txt_email = QtWidgets.QLineEdit(self.widget4)
self.txt_email.setClearButtonEnabled(True)
self.txt_email.setObjectName("txt_email")
self.horizontalLayout_6.addWidget(self.txt_email)
self.verticalLayout_2.addLayout(self.horizontalLayout_6)
self.horizontalLayout_7 = QtWidgets.QHBoxLayout()
self.horizontalLayout_7.setObjectName("horizontalLayout_7")
self.label_6 = QtWidgets.QLabel(self.widget4)
self.label_6.setObjectName("label_6")
self.horizontalLayout_7.addWidget(self.label_6)
spacerItem2 = QtWidgets.QSpacerItem(72, 20, QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_7.addItem(spacerItem2)
self.txt_passwd = QtWidgets.QLineEdit(self.widget4)
self.txt_passwd.setFrame(True)
self.txt_passwd.setEchoMode(QtWidgets.QLineEdit.PasswordEchoOnEdit)
self.txt_passwd.setClearButtonEnabled(True)
self.txt_passwd.setObjectName("txt_passwd")
self.horizontalLayout_7.addWidget(self.txt_passwd)
self.verticalLayout_2.addLayout(self.horizontalLayout_7)
self.widget5 = QtWidgets.QWidget(self.t_stngs)
self.widget5.setGeometry(QtCore.QRect(10, 140, 960, 27))
self.widget5.setObjectName("widget5")
self.horizontalLayout_8 = QtWidgets.QHBoxLayout(self.widget5)
self.horizontalLayout_8.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_8.setObjectName("horizontalLayout_8")
self.label_7 = QtWidgets.QLabel(self.widget5)
self.label_7.setObjectName("label_7")
self.horizontalLayout_8.addWidget(self.label_7)
self.txt_api_key = QtWidgets.QLineEdit(self.widget5)
self.txt_api_key.setClearButtonEnabled(True)
self.txt_api_key.setObjectName("txt_api_key")
self.horizontalLayout_8.addWidget(self.txt_api_key)
self.widget6 = QtWidgets.QWidget(self.t_stngs)
self.widget6.setGeometry(QtCore.QRect(10, 185, 341, 61))
self.widget6.setObjectName("widget6")
self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.widget6)
self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.horizontalLayout_9 = QtWidgets.QHBoxLayout()
self.horizontalLayout_9.setObjectName("horizontalLayout_9")
self.label_8 = QtWidgets.QLabel(self.widget6)
self.label_8.setObjectName("label_8")
self.horizontalLayout_9.addWidget(self.label_8)
self.lbl_plan_type = QtWidgets.QLabel(self.widget6)
self.lbl_plan_type.setText("")
self.lbl_plan_type.setObjectName("lbl_plan_type")
self.horizontalLayout_9.addWidget(self.lbl_plan_type)
self.verticalLayout_3.addLayout(self.horizontalLayout_9)
self.horizontalLayout_10 = QtWidgets.QHBoxLayout()
self.horizontalLayout_10.setObjectName("horizontalLayout_10")
self.label_9 = QtWidgets.QLabel(self.widget6)
self.label_9.setObjectName("label_9")
self.horizontalLayout_10.addWidget(self.label_9)
self.lbl_expiry = QtWidgets.QLabel(self.widget6)
self.lbl_expiry.setText("")
self.lbl_expiry.setObjectName("lbl_expiry")
self.horizontalLayout_10.addWidget(self.lbl_expiry)
self.verticalLayout_3.addLayout(self.horizontalLayout_10)
self.widget7 = QtWidgets.QWidget(self.t_stngs)
self.widget7.setGeometry(QtCore.QRect(630, 220, 341, 28))
self.widget7.setObjectName("widget7")
self.horizontalLayout_11 = QtWidgets.QHBoxLayout(self.widget7)
self.horizontalLayout_11.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_11.setObjectName("horizontalLayout_11")
self.label_10 = QtWidgets.QLabel(self.widget7)
self.label_10.setObjectName("label_10")
self.horizontalLayout_11.addWidget(self.label_10)
self.delay = QtWidgets.QSpinBox(self.widget7)
self.delay.setMinimum(10)
self.delay.setMaximum(20)
self.delay.setObjectName("delay")
self.horizontalLayout_11.addWidget(self.delay)
self.tabWidget.addTab(self.t_stngs, "")
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Linkedin Recent Connection Messenger"))
self.label_4.setText(_translate("MainWindow", "<html><head/><body><p>Use <span style=\" font-style:italic;\">{{name}}</span> for dynamic naming</p></body></html>"))
self.label.setText(_translate("MainWindow", "Recent Profiles"))
self.btn_fetch.setText(_translate("MainWindow", "Fetch"))
self.btn_save_template.setText(_translate("MainWindow", "Save Template"))
self.btn_send_all.setText(_translate("MainWindow", "Send To All"))
self.label_2.setText(_translate("MainWindow", "Search By"))
self.search_predicate.setItemText(0, _translate("MainWindow", "Days"))
self.search_predicate.setItemText(1, _translate("MainWindow", "Weeks"))
self.search_predicate.setItemText(2, _translate("MainWindow", "Months"))
self.search_predicate.setItemText(3, _translate("MainWindow", "Years"))
self.searchee.setText(_translate("MainWindow", "Search Limit"))
self.label_3.setText(_translate("MainWindow", "Template"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.t_msngr), _translate("MainWindow", "Messenger"))
self.btn_save_settings.setText(_translate("MainWindow", "Save All"))
self.label_5.setText(_translate("MainWindow", "Email Address"))
self.label_6.setText(_translate("MainWindow", "Password"))
self.label_7.setText(_translate("MainWindow", "API Key"))
self.label_8.setText(_translate("MainWindow", "Plan Type"))
self.label_9.setText(_translate("MainWindow", "Expiry Date"))
self.label_10.setText(_translate("MainWindow", "Delay"))
self.delay.setSuffix(_translate("MainWindow", " secs"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.t_stngs), _translate("MainWindow", "Settings"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment