-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrapecinema.py
More file actions
87 lines (76 loc) · 2.8 KB
/
scrapecinema.py
File metadata and controls
87 lines (76 loc) · 2.8 KB
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
77
78
79
80
81
82
83
84
85
86
87
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import time
class Smartcinema():
def __init__(self, browsingMode):
self.browsingMode = browsingMode
self.browserProfile = webdriver.ChromeOptions()
self.browserProfile.add_argument(browsingMode)
self.browser = webdriver.Chrome(chrome_options=self.browserProfile)
def goToPage(self):
self.browser.get('https://smartcinema.co/')
print('Browser initialized successfully')
time.sleep(2)
self.browser.maximize_window()
print('Maximized')
time.sleep(1)
def clickAround(self):
driver = self.browser
actions = ActionChains(driver)
browsingMode = self.browsingMode
detailBtn = driver.find_element_by_css_selector('.et_pb_more_button')
arrowNext = driver.find_element_by_css_selector('.et-pb-arrow-next')
arrowPrev = driver.find_element_by_css_selector('.et-pb-arrow-prev')
showPrograme = driver.find_element_by_xpath("//*[contains(text(), 'Show programe')]")
time.sleep(2)
detailBtn.click()
print('Clicked the detail button')
time.sleep(1)
detailBtn.click()
print('Clicked the detail button')
time.sleep(1)
arrowNext.click()
print('Clicked the right arrow button')
time.sleep(3)
arrowNext.click()
print('Clicked the right arrow button')
time.sleep(3)
arrowPrev.click()
print('Clicked the left arrow button')
time.sleep(3)
time.sleep(2)
print(showPrograme.location)
if(browsingMode == '--kiosk'):
showPrograme.click()
print('Clicked the show programe button')
buyFilms = driver.find_element_by_id('menu-item-48')
buyFilms.click()
print('Clicked the buy films button')
if(browsingMode == 'headless'):
burgerMenu = driver.find_element_by_class_name('mobile_menu_bar_toggle')
burgerMenu.click()
print('Clicked the burger nav menu')
time.sleep(1)
buyFilms = driver.find_element_by_id('menu-item-48')
print(buyFilms.location)
actions.move_to_element(buyFilms)
driver.save_screenshot('tablet.png')
# buyFilms.click()
# print('Clicked the buy films button')
time.sleep(2)
def closeBrowser(self):
self.browser.close()
print('Browser closed successfully')
def browse_on_desktop():
auto = Smartcinema('--kiosk')
auto.goToPage()
auto.clickAround()
auto.closeBrowser()
def browse_on_tablet():
auto = Smartcinema('headless')
auto.goToPage()
auto.clickAround()
auto.closeBrowser()
browse_on_desktop()
time.sleep(2)
browse_on_tablet()