Skip to content

Commit

Permalink
Fix #2
Browse files Browse the repository at this point in the history
- Fix Bing search
- Add Google and Startpage scrapers (change in ui settings)
- Fix headers + add header randomizer
- Completely remove Brainly from the project due to new WAF + slow processing time
- Fix delay in cursor restoring after OCR
- Manually calculate selection rectangle for OCR
- Change minimum value for window transparency slider to 5%
- Upgrade Pillow and pytesseract to fix security concerns
- Add requests_html, fake_headers, and their dependencies to requirements.txt
  • Loading branch information
daijro committed Apr 11, 2022
1 parent 6e7c123 commit 2e854a4
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 138 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"quizlet": true,
"quizizz": true,
"brainly": false,
"search_engine": 0,
"hide_show_key": "Ctrl+D",
"ocr_key": "Ctrl+Shift+X",
"paste_key": "Ctrl+Shift+V",
Expand Down
23 changes: 13 additions & 10 deletions gui.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import tkinter as tk
root = tk.Tk()
root.withdraw()

from scraper import Searchify
from scraper import Searchify, SearchEngine
from textshot import *
from windoweffect import WindowEffect

Expand Down Expand Up @@ -96,17 +96,13 @@ class UI(QMainWindow):
self.status_label = self.findChild(QtWidgets.QLabel, "status_label")
self.quizlet_button = self.findChild(QtWidgets.QPushButton, "quizlet_button")
self.quizizz_button = self.findChild(QtWidgets.QPushButton, "quizizz_button")
self.brainly_button = self.findChild(QtWidgets.QPushButton, "brainly_button")
self.settings_button = self.findChild(QtWidgets.QPushButton, "settings_button")

self.quizlet_button.setChecked(self.conf['quizlet'])
self.quizizz_button.setChecked(self.conf['quizizz'])
self.brainly_button.setChecked(self.conf['brainly'])

self.quizlet_button.toggled.connect(lambda: self.updatejson('quizlet'))
self.quizizz_button.toggled.connect(lambda: self.updatejson('quizizz'))
self.brainly_button.toggled.connect(lambda: self.updatejson('brainly'))


self.settings_button.clicked.connect(lambda: self.stackedWidget.setCurrentIndex(1))

Expand All @@ -115,7 +111,6 @@ class UI(QMainWindow):

self.quizizz_button.setIcon(QtGui.QIcon(resource_path("img\\quizizz.png")))
self.quizlet_button.setIcon(QtGui.QIcon(resource_path("img\\quizlet.png")))
self.brainly_button.setIcon(QtGui.QIcon(resource_path("img\\brainly.png")))
self.titleIcon.setPixmap(QtGui.QPixmap(resource_path("img\\search.png")))


Expand Down Expand Up @@ -203,6 +198,11 @@ class UI(QMainWindow):

self.setting_on_top.setChecked(self.conf['on_top'])
self.setting_on_top.toggled.connect(lambda: self.set_window_on_top())

self.search_engine_combo = self.findChild(QtWidgets.QComboBox, "search_engine_combo")
self.search_engine_combo.setCurrentIndex(self.conf['search_engine'])
self.search_engine = SearchEngine(self.search_engine_combo.currentText().lower())
self.search_engine_combo.currentIndexChanged.connect(lambda: self.run_search_engine())

# window theme
self.themeInput = self.findChild(QtWidgets.QComboBox, "themeInput")
Expand Down Expand Up @@ -291,7 +291,7 @@ class UI(QMainWindow):
font_size = self.font_size.value()

# icon sizes
for obj in [self.quizizz_button, self.quizlet_button, self.brainly_button]:
for obj in [self.quizizz_button, self.quizlet_button]:
obj.setIconSize(QtCore.QSize(font_size*2, font_size*2))


Expand All @@ -313,6 +313,10 @@ class UI(QMainWindow):

# calling scraper and adding to ui

def run_search_engine(self):
self.search_engine = SearchEngine(self.search_engine_combo.currentText().lower())
self.updatejson('search_engine')

def run_searcher(self):
query = self.search_bar.text().strip()

Expand All @@ -328,14 +332,13 @@ class UI(QMainWindow):

if self.quizizz_button.isChecked(): sites.append('quizizz')
if self.quizlet_button.isChecked(): sites.append('quizlet')
if self.brainly_button.isChecked(): sites.append('brainly')

if not sites:
self.status_label.setText('Please select at least one site.')
self.search_frame.setEnabled(True)
return

searchify = Searchify(query, sites)
searchify = Searchify(query, sites, self.search_engine)

t = Thread(target=searchify.main)
t.daemon = True
Expand Down Expand Up @@ -530,7 +533,6 @@ class UI(QMainWindow):
# keybinds
"quizlet": lambda: self.quizlet_button.isChecked(),
"quizizz": lambda: self.quizizz_button.isChecked(),
"brainly": lambda: self.brainly_button.isChecked(),
"hide_show_key": lambda: self.hide_show_key.keySequence().toString(),
"ocr_key": lambda: self.ocr_key.keySequence().toString(),
"paste_key": lambda: self.paste_key.keySequence().toString(),
Expand All @@ -550,6 +552,7 @@ class UI(QMainWindow):
"hide_taskbar": lambda: self.setting_hide_taskbar.isChecked(),
"theme": lambda: self.themeInput.currentIndex(),
"font_size": lambda: self.font_size.value(),
"search_engine": lambda: self.search_engine_combo.currentIndex(),
}

def updatejson(self, key):
Expand Down
Binary file removed img/brainly.png
Binary file not shown.
26 changes: 24 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
appdirs==1.4.4
beautifulsoup4==4.10.0
bs4==0.0.1
certifi==2021.10.8
cffi==1.15.0
charset-normalizer==2.0.9
colorama==0.4.4
cssselect==1.1.0
fake-headers==1.0.2
fake-useragent==0.1.11
gevent==21.12.0
greenlet==1.1.2
grequests==0.6.0
html5lib==1.1
idna==3.3
importlib-metadata==4.11.3
keyboard==0.13.5
Pillow==8.4.0
lxml==4.8.0
packaging==21.3
parse==1.19.0
Pillow==9.1.0
pycparser==2.21
pyee==8.2.2
pyparsing==3.0.8
pyperclip==1.8.2
pyppeteer==1.0.2
PyQt5==5.15.6
PyQt5-Qt5==5.15.2
PyQt5-sip==12.9.0
pytesseract==0.3.8
pyquery==1.4.3
pytesseract==0.3.9
pywin32==303
requests==2.26.0
requests-html==0.10.0
six==1.16.0
soupsieve==2.3.1
tqdm==4.64.0
urllib3==1.26.7
w3lib==1.22.0
webencodings==0.5.1
websockets==10.2
zipp==3.8.0
zope.event==4.5.0
zope.interface==5.4.0
Loading

0 comments on commit 2e854a4

Please sign in to comment.