Parsing text within iframe

How do I parse a text string on a web page with an iframe? The string is within the iframe.

What I am trying to do is determine whether the iframe is properly loading. Then if it is not write a timestamp and error message to the disk.
LVL 1
sparkie_77Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rahulbhanotCommented:
Please littlebit explain more about your problem with iframe and then we will definitely give you the appropriate solution of code.


--Rahul--
0
gemdeals395Commented:
Are you wanting to test a remote page from your script? If your wanting to test like that just use preg_match() like this:

$iframe = array();

$url = 'http://www.urltoparse.com';

$ch_one = curl_init();
curl_setopt($ch_one, CURLOPT_URL, $url);
curl_setopt($ch_one, CURLOPT_REFERER, 'http://www.yoursite.com');
curl_setopt($ch_one, CURLOPT_HEADER, 1);
curl_setopt($ch_one, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch_one, CURLOPT_USERAGENT, "$_SERVER[HTTP_USER_AGENT]");
curl_setopt($ch_one, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch_one, CURLOPT_TIMEOUT, 5);
$result_one = curl_exec($ch_one);
curl_close($ch_one);

preg_match("/<iframe>(.*?)'</iframe>/", $result_one, $iframe);

//Now $iframe is an array and your parsed result of everything between the <iframe> tags is stored in the array location [1]. You can now run tests againts this such as this.

if (strlen($iframe[1] == '0') {
    //nothing was loaded , do something. Now to make sure you didnt get a partial load or anything it would probably be a good idea to keep a cache copy of the html to compare against stored on your end that gets updated every so often and compare what was loaded like so.
} elseif ($iframe[1] != $url.cache) {
    //What was loaded did not match what we expected. Do something.
}

Maybe that will point you in the right direction. :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.