11.9 Interacting with Frames


11.9 Interacting with Frames

You are accessing a Web site that uses frames and you want to fetch the contents of an individual frame.

Technique

Use the Snoopy class (available from http://snoopy. sourceforge .net/), which supports fetching individual frames:

 <?php include_once 'Snoopy.class.inc'; $snoopy = new Snoopy; $snoopy->maxframes = 3; $snoopy->fetch('http://www.ispi.net/'); print "The middle frame has the following contents: "; print "\n<br>\n<br>\n<br>\n"; print htmlentities($snoopy->results[1]); ?> 

Comments

Snoopy , available from http://snoopy.sourceforge.net/, fetches frames for you. In the example, we initialize the Snoopy class, set the maxframes property to the maximum number of frames to fetch ( 3 ), and then use the fetch() method to fetch the page. After we've fetched the page, we access the middle frame (the frames are stored in a numerically indexed array), and print its contents.



PHP Developer's Cookbook
PHP Developers Cookbook (2nd Edition)
ISBN: 0672323257
EAN: 2147483647
Year: 2000
Pages: 351

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net