I want to get video URL starting from this page: https://farsiland.com/movies/portrait-of-a-lady-far-away/ which leads to this page: https://farsiland.com/play/ . I am able to automate the direct the first page into the second page by clicking on the icon (xPath) but I can't get any of below (which shows on Chrome's Devs Tools) using Python Selenium and Chrome wabdriver.
I want this
https:\/\/serp.seocheck.one\/movies\/Simaye.Zani.Dar.Doordast.1382.VCDRip.Per.mp4from here:var jw = {"file":"https:\/\/serp.seocheck.one\/movies\/Simaye.Zani.Dar.Doordast.1382.VCDRip.Per.mp4","file2":"https:\/\/steam.filmestoon.com\/movies\/Simaye.Zani.Dar.Doordast.1382.VCDRip.Per.mp4","image":"https:\/\/image.tmdb.org\/t\/p\/original\/qQ0bUacVseAnFMqi70rdPC3FWoz.jpg","color":"#0b7ef4","title":"Simaye Zani Dar Door Dast","sub":"https:\/\/farsiland.com\/caption.srt?","link":"https:\/\/farsiland.com","logo":"https:\/\/farsiland.com\/wp-content\/uploads\/2019\/10\/dark-logo.png","auto":"false","text":"FarsiLand Player","lposi":"top-left","flash":"https:\/\/farsiland.com\/wp-content\/themes\/newfarsiland\/assets\/jwplayer\/jwplayer.flash.swf","postid":"1198"}orthis one https://serp.seocheck.one/movies/Simaye.Zani.Dar.Doordast.1382.VCDRip.Per.mp4 from here
<video tabindex="-1" disableremoteplayback="" webkit-playsinline="" playsinline=""title="Simaye Zani Dar Door Dast" preload="metadata" src="https://serp.seocheck.one/movies/Simaye.Zani.Dar.Doordast.1382.VCDRip.Per.mp4"></video>
Here are my webdriver options arguments:
chrome_options.add_argument("--incognito")
chrome_options.add_argument("user-agent=%s"%HEADERS['User-Agent'])
chrome_options.add_argument("--disable-notifications")
chrome_options.add_argument("--disable-popup-blocking")
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_options.add_experimental_option('useAutomationExtension', False)
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
And here's my code:
url = "https://farsiland.com/movies/portrait-of-a-lady-far-away/"
xPath = "//*[@id=\"fakeplayer\"]/a/div/span[2]/img"
driver = webdriver.Chrome("chromedriver.exe", options=chrome_options)
driver.get(url)
time.sleep(10)
driver.find_element(By.XPATH, xPath).click()
time.sleep(10)
something = driver.find_element(By.CSS_SELECTOR, "#player > source")
print(something, file=codecs.open("output.txt","w","utf-8"))
driver.quit()
Your help is highly appreciated.
CodePudding user response:
The video is actually inside an iframe. You'll need to navigate directly to the iframe src page before you can get to the video element's src.
Try this:
iframe = driver.find_element(By.CSS_SELECTOR, "iframe.metaframe")
driver.get(iframe.get_attribute('src'))
time.sleep(10)
video = driver.find_element(By.CSS_SELECTOR, "video.jw-video")
print(video.get_attribute('src'))
