mnybud Posted August 3, 2008 Share Posted August 3, 2008 Can someone help me out. I am trying to figure out how to do something I think is pretty simple but I am a total PHP newbie. All I want to do is take a list of urls I have in a text file and load each of them one at a time like you would a browser but as fast as possible. Can someone supply me with code to do this or help point me in the right direction. Quote Link to comment Share on other sites More sharing options...
Third_Degree Posted August 3, 2008 Share Posted August 3, 2008 <?php $urls = file( 'urls.txt' ); foreach ( $urls as $url ) { fopen( $url, "r" ); } ?> Quote Link to comment Share on other sites More sharing options...
mnybud Posted August 3, 2008 Author Share Posted August 3, 2008 thanks a lot, looks like what I need. I will try it out. Thank you!! Quote Link to comment Share on other sites More sharing options...
mnybud Posted August 3, 2008 Author Share Posted August 3, 2008 Is it possible to set a cookie with the script so it logged me into my site before running the links? Quote Link to comment Share on other sites More sharing options...
jonsjava Posted August 3, 2008 Share Posted August 3, 2008 <?php echo<<<END <html> <head> <script type="text/javascript"> function open_win() { END; $data = file("text_file.txt"); foreach ($data as $value){ print "\t window.open(\"$value\")\n"; } echo <<<END </script> </head> <body onload="open_win()"> </body> </html> END; ?> my window open variety will open multiple windows/tabs (one for each link) for you. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted August 3, 2008 Share Posted August 3, 2008 if the cookie is not for your site, you can't write one. Quote Link to comment Share on other sites More sharing options...
mnybud Posted August 3, 2008 Author Share Posted August 3, 2008 the cookie is for just my site (lots of urls from same domain). so how would that work? how does it login to set the cookie originally? thanks again for your help, helping me learn Quote Link to comment Share on other sites More sharing options...
jonsjava Posted August 3, 2008 Share Posted August 3, 2008 do all the pages use cookies, or do some use cookies, and some sessions? They are the same thing, basically (well....), but how you set them varies between the two. Both require you to have session_start(); at the top of the page. That's a start. Quote Link to comment Share on other sites More sharing options...
mnybud Posted August 3, 2008 Author Share Posted August 3, 2008 they use the same cookie. I login once and then I am good to view all the urls. Also I dont really want to load the page in the browser, just go through the list of urls as quick as possible. wont actually loading them be slower than just processing them in the background skipping images and stuff? Quote Link to comment Share on other sites More sharing options...
jonsjava Posted August 3, 2008 Share Posted August 3, 2008 Can someone help me out. I am trying to figure out how to do something I think is pretty simple but I am a total PHP newbie. All I want to do is take a list of urls I have in a text file and load each of them one at a time like you would a browser but as fast as possible. Can someone supply me with code to do this or help point me in the right direction. I was following your origional request. Load the files like in a browser (well, I loaded them in a browser), and have it load them as fast as possible. The only thing I know of that's faster is Linux wget Quote Link to comment Share on other sites More sharing options...
mnybud Posted August 3, 2008 Author Share Posted August 3, 2008 ok thanks for your help. I will explore more. You gave me a good start Quote Link to comment Share on other sites More sharing options...
Third_Degree Posted August 4, 2008 Share Posted August 4, 2008 Is it possible to set a cookie with the script so it logged me into my site before running the links? You could use curl (cURL Basics), and then use CURLOPT_COOKIE in curl_setopt() to define it. 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.