-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.py
111 lines (80 loc) · 3.94 KB
/
temp.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ChromeOptions
from selenium.webdriver.common.action_chains import ActionChains
def hoomock(driver:webdriver.Chrome):#for hooman mocker "used to fool adblocker detector by actually watching the ad :'("
while(True):
elm=driver.find_element(By.XPATH,"//a[@class='bigbutton _reload']")
elm.click()
#preventing getting detected by adblocker detection by openning the ad
driver.switch_to.window(driver.window_handles[2])
ad=WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.XPATH, "/html/head/title")))
while(ad.text=='Redirect'):
ad=WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.XPATH, "/html/head/title")))
driver.switch_to.window(driver.window_handles[1])
try:
elm=WebDriverWait(driver, 1).until(EC.presence_of_element_located((By.XPATH, '//a[@href^="https"]')))
break
except Exception:
pass
elm=driver.find_element(By.XPATH,"//a[@class='bigbutton _reload']")
def downep(url):
drivep=webdriver.Chrome('C:\webdrivers\chromedriver.exe')
getweb(drivep,url)
# downlink=drivep.find_element(By.CLASS_NAME,'nop btn g dl _open_window')
downlink=WebDriverWait(drivep, 10).until(EC.presence_of_element_located((By.NAME, 'q')))
downlink.click()
print("stage:101")
drivep.switch_to.window(drivep.window_handles[1])
ad=WebDriverWait(drivep, 3).until(EC.presence_of_element_located((By.XPATH, "/html/head/title")))
while(ad.text=='Redirect'):
ad=WebDriverWait(drivep, 3).until(EC.presence_of_element_located((By.XPATH, "/html/head/title")))
drivep.switch_to.window(drivep.window_handles[0])
downlink=drivep.find_elements(By.XPATH,"//a[@class='nop btn g dl _open_window']")
print(len(downlink))
downlink[1].click()
time.sleep(0.2)
drivep.switch_to.window(drivep.window_handles[1])
try:
bigfinale=WebDriverWait(drivep, 1).until(EC.presence_of_element_located((By.XPATH, '//a[@href^="https"]')))
except Exception:
bigfinale=WebDriverWait(drivep, 3).until(EC.presence_of_element_located((By.XPATH, "//a[@class='bigbutton _reload']")))
hoomock(drivep)
bigfinale=WebDriverWait(drivep, 1).until(EC.presence_of_element_located((By.XPATH, '//a[@href^="https"]')))
#*********************special moment*************************************
bigfinale.click()
def getweb(driver:webdriver,url):
try:
driver.get(url)
except Exception:
getweb(driver, url)
start=int(input("enter episode number where u want to start downloading:"))
end=int(input("enter episode number where u want to stop downloading (the one you enter is included):"))
#-----------------------------------------------------------------#
# Open browser and facebook code
driver = webdriver.Chrome('C:\webdrivers\chromedriver.exe')
getweb(driver, "https://poly.egybest.me/episode/suits-arabic-season-1-ep-13/")
driver.implicitly_wait(5)
#-----------------------------------------------------------------#
# get a list with all episodes
# search=driver.find_element(By.CLASS_NAME,'movies_small')
search=WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'movies_small')))
listEps=search.find_elements(By.CLASS_NAME,'movie')
current=len(listEps)
for i in listEps:
if(current>=start and current<=end):
link=i.get_attribute('href')
try:
downep(link)
except Exception:
pass
current-=1