-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlubimy_czytac_site_handling.py
76 lines (64 loc) · 1.78 KB
/
lubimy_czytac_site_handling.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import re
import time
import pyautogui
import pyperclip
def search_for_a_book():
"""
Function to search for a book on lubimyczytać.pl. It needs to have book title already in clipboard when called
:return:
"""
pyautogui.press('home')
time.sleep(0.25)
pyautogui.click(1567, 400)
time.sleep(0.25)
pyautogui.hotkey('ctrl', 'v')
time.sleep(2.5)
pyautogui.click(1443, 470)
time.sleep(5)
return check_if_book_found()
def check_publication_date():
"""
Function to get publication date of the book. Assumes it is already on target book's site
:return: Publication date of the book (in clipboard)
"""
pyautogui.click(825, 1029)
time.sleep(1)
pyautogui.moveTo(1015, 1083)
time.sleep(0.25)
pyautogui.mouseDown()
pyautogui.drag(39, 0)
pyautogui.mouseUp()
time.sleep(0.25)
pyautogui.hotkey('ctrl', 'c')
time.sleep(0.25)
def get_desc():
"""
Function to get description of the book. Assumes it is already on target book's site
:return: Description of the book (in clipboard)
"""
pyautogui.hotkey('ctrl', 'u')
time.sleep(5)
pyautogui.hotkey('ctrl', 'a')
time.sleep(1)
pyautogui.hotkey('ctrl', 'c')
time.sleep(1)
pyautogui.hotkey('ctrl', 'w')
full_site_text = pyperclip.paste()
raw_desc = full_site_text.split('<div class="collapse-content">')[1].split('</div>')[0]
raw_desc = raw_desc.replace("<br />", "").replace("<p>", "").replace("</p>", "")
raw_desc = raw_desc.strip()
print(raw_desc)
return raw_desc
def check_if_book_found():
"""
Function to check if the book was found
:return: 0 if it wasn't found (so search_for_a_book() entered the wrong site), 1 otherwise
"""
pyautogui.click(1445, 66)
pyautogui.hotkey('ctrl', 'c')
website = pyperclip.paste()
print(website)
if website == "https://lubimyczytac.pl/mapaksiegarn":
print("Book not found")
return 0
return 1