-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUNOGS_bot.py
64 lines (58 loc) · 2.53 KB
/
UNOGS_bot.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
from selenium import webdriver
from time import sleep
nflx_scraper=0
class UNOGSBot():
def __init__(self,headless=0):
options=webdriver.ChromeOptions()
if headless:
options.add_argument('--ignore-certificate-errors')
options.add_argument('--headless')
options.add_argument('start-maximized')
options.add_argument('disable-infobars')
options.add_argument('--disable-extensions')
options.add_argument('--disable-gpu')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
self.driver=webdriver.Chrome(options=options)
self.driver.get('https://unogs.com')
print('Webdriver initiated')
sleep(1)
def search(self, s):
##search movie and go
#search_field = self.driver.find_element_by_xpath('//*[@id="navbar"]/form/div/input')
#search_field.click()
#search_field.clear()
#search_field.send_keys(s)
#go_btn= self.driver.find_element_by_xpath('//*[@id="navbar"]/form/div/span[2]/input')
#go_btn.click()
#sleep(1)
print('Webdriver: %s' % s)
self.driver.get('https://unogs.com/search/'+s.replace(' ', '%20'))
sleep(1)
print('Webdriver: searching %s' % s)
#find first result and click to expand
first_result=self.driver.find_elements_by_xpath('/html/body/div[9]/div[1]/div[2]/div')
if first_result:
first_result[0].click()
sleep(1)
#find if germany is there
de_card=self.driver.find_elements_by_xpath('//*[@id="titleDetails"]/div/div/div[3]/div[3]/div[5]/div[3]/*[@id="39"]')
if de_card:
print('Title is available in germany: %s' % s)
#get url title for movie on netflix
title=self.driver.find_element_by_xpath('//*[@id="titleDetails"]/div/div/div[1]/h4/a')
sleep(1)
text=title.text
x=self.driver.find_element_by_xpath('//*[@id="titleDetails"]/div/div/div[1]/button')
x.click()
sleep(0.2)
return text
else:
print('Title is not available in germany: %s' % s)
x=self.driver.find_element_by_xpath('//*[@id="titleDetails"]/div/div/div[1]/button')
x.click()
sleep(0.2)
return ''
print('Title could not be found: %s' % s)
return ''
if nflx_scraper: bot=UNOGSBot(headless=1)