-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdoubtnutvid.py
33 lines (24 loc) · 935 Bytes
/
doubtnutvid.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
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
import json
#get link to doubtnut site from user
link = input("Enter link: " )
#selenium setup
cap = DesiredCapabilities().CHROME
cap["pageLoadStrategy"] = "eager"
options = Options()
options.add_argument('--headless=new')
options.add_argument("--log-level=3")
driver = webdriver.Chrome(options=options)
driver.get(link)
#locating element and extracting required values
ele = driver.find_element(By.XPATH, "/html/body/script")
raw_data = ele.get_attribute("innerHTML")
compiledData = json.loads(raw_data)
videoName = compiledData["props"]["pageProps"]["videoData"]["video_name"]
#output video link
driver.close()
print("https://videos.doubtnut.com/"+videoName)