SidewinderX Posted March 13, 2007 Share Posted March 13, 2007 Ive created a script to login to a site which works fine, but when I login, that site has an iframe I want to grab data from. The problem is the iframe displays a 404 error because the file it is looking for is account.php which is not on my server, but the server i am logging into. Using my script, how can I get access to the file thats in the iframe? <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "C:/"); curl_setopt($ch, CURLOPT_COOKIEFILE, "C:/"); curl_setopt($ch, CURLOPT_URL, $host."/myaccount.php?"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "login_username=".$username."&login_password=".$password.""); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_exec($ch); curl_close ($ch); ?> Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted March 13, 2007 Share Posted March 13, 2007 The PHP won't look for anything on your local server. cURL is a browser and browses to the url like you would in Firefox. The only stuff you'd download is HTML and JS. The iFrame will load a web page like a normal frame. So look for the URL it is loading and grab that. monk.e.boy Quote Link to comment Share on other sites More sharing options...
SidewinderX Posted March 13, 2007 Author Share Posted March 13, 2007 the direct link to the iframe would be $host."accounts.php?ac_serverid=4" so how would i go about doing that? Quote Link to comment Share on other sites More sharing options...
Orio Posted March 13, 2007 Share Posted March 13, 2007 If you want to know what's inside, use curl to fetch $host."accounts.php?ac_serverid=4"... Orio. Quote Link to comment Share on other sites More sharing options...
SidewinderX Posted March 13, 2007 Author Share Posted March 13, 2007 and you do that by using fopen? Quote Link to comment Share on other sites More sharing options...
Orio Posted March 13, 2007 Share Posted March 13, 2007 You could use the file functions or curl or whatever you want... Orio. Quote Link to comment Share on other sites More sharing options...
SidewinderX Posted March 13, 2007 Author Share Posted March 13, 2007 $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "C:/"); curl_setopt($ch, CURLOPT_COOKIEFILE, "C:/"); curl_setopt($ch, CURLOPT_URL,$host."myaccount.php"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "login_username=".$username."&login_password=".$password.""); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_exec($ch); $fp = fopen($host."accounts.php?ac_serverid=4", "r"); curl_close ($ch); fclose($fp); echo $fp; Yields: Resource id #4 Not exactly what im looking for ??? Quote Link to comment Share on other sites More sharing options...
monk.e.boy Posted March 14, 2007 Share Posted March 14, 2007 READ THE CURL DOCUMENTATION: http://uk.php.net/curl <?php $pageurl = $host."myaccount.php" curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_URL, $pageurl ); $html = curl_exec ( $ch ); curl_close($ch); $pageurl = $host."accounts.php?ac_serverid=4"; curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_URL, $pageurl ); $html2 = curl_exec ( $ch ); curl_close($ch); ?> monk.e.boy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.