0

I have been trying to extract the src which is a openload link from a website. The src is loacted in iframe which is loaded dynamically. the website is "https://www1.fmovies.se/film/daddys-home-2.kk29w". Now The problem is that iframe is loaded dynamically. So this is my code

from selenium import webdriver
driver=webdriver.Chrome('C:\\Users\\aman krishna\Desktop\\New folder(3)\chromedriver.exe')
driver.get("https://bmovies.to/film/daddys-home-2.kk29w/78vp5j")
driver.find_element_by_xpath("//iframe[contains(@src,'<https://openload.co/embed/qe3n5GZGyGo/?autostart=true')]")
  • uhh did you not copy all of your code into the question? – Sean Breckenridge Mar 03 '18 at 10:25
  • It's good that you have a specific example to illustrate your issue, but your example uses a website that as far as I can tell is illegal in the vast majority of jurisdiction in which it will be viewed. Pick something more benign please. – AnOccasionalCashew Mar 03 '18 at 10:46
  • Check [this answer](https://stackoverflow.com/questions/7534622/selecting-an-iframe-using-python-selenium/48729644#48729644) to be able to handle dynamic frame – Andersson Mar 03 '18 at 10:48
  • 1
    This would require much more than just loading the page. This sort of page tends to not finish loading for a while, so I'd set `driver.set_page_load_timeout(15)`, and then surround your `driver.get()` statement in `try: except: pass` blocks to manually limit incase something goes wrong (or use ExpectedConditions). Then use `driver.find_element_by_css_selector` (or something similar) to click on the `iframe`, [close any tabs that might pop up because of ads](https://stackoverflow.com/q/40458138/9348376), wait till the iframe has a src, and then get the iframe src. – Sean Breckenridge Mar 03 '18 at 11:01
  • Thank you guys. I was able to do it by sending some of the clicks and getting the page source. – aman krishna Mar 20 '18 at 14:45

1 Answers1

0

I could spoon feed you the code, as I wrote my own scraper with python that is eerily similar to what you've posted. but that wouldn't help you in the long run.

I'll give you a hint though. Use var box and var frames to get what you need.

x6god
  • 32
  • 2
  • Thank you for your suggestion. I used your hint and stored all the values in a list and the Iterated through it to get my desired result. – aman krishna Mar 20 '18 at 14:46