0
require('simple_html_dom.php');
    // Create DOM from URL or file
    $html = file_get_html('https://www7.fmovies.se/film/hometown-hero.m2r28/6xpjrp');
    foreach($html->find('div[id=player]') as $div)
    {
     foreach($div->find('iframe') as $iframe)
       {
             echo $iframe->src;

       }
    }

This is my code and as you see I'm trying to get the src of the iframe under the player div using PHP Simple HTML DOM Parser, can you explain to me why I'm getting a blank page as a result? Thanks!

UPDATE: After using a javascript switcher addon and disabling javascript, I noticed that the iframe I'm looking for is not loaded. What should I do to get the iframe src?

2
  • Go to that page, view the source and search for "<iframe". That's your first step to realizing what's going on here. Commented Jul 10, 2018 at 10:35
  • @pguardiario the iframe is loaded after a click which executes a javascript code that loads the iframe Commented Jul 10, 2018 at 15:17

1 Answer 1

1

There are two possible solutions;

  1. Try to figure out how the javascript works, and mock this behavior in your PHP script.

  2. Let the page load in, for example, selenium and then grab the SRC from the iframe using selenium. (https://www.seleniumhq.org/)

Hope this helps

Sign up to request clarification or add additional context in comments.

1 Comment

thank you for your reply, the iframe is loaded after a link click via javascript

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.