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. Link to comment https://forums.phpfreaks.com/topic/117907-load-list-of-urls/ 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" ); } ?> Link to comment https://forums.phpfreaks.com/topic/117907-load-list-of-urls/#findComment-606498 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!! Link to comment https://forums.phpfreaks.com/topic/117907-load-list-of-urls/#findComment-606499 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? Link to comment https://forums.phpfreaks.com/topic/117907-load-list-of-urls/#findComment-606500 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. Link to comment https://forums.phpfreaks.com/topic/117907-load-list-of-urls/#findComment-606502 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. Link to comment https://forums.phpfreaks.com/topic/117907-load-list-of-urls/#findComment-606504 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 Link to comment https://forums.phpfreaks.com/topic/117907-load-list-of-urls/#findComment-606507 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. Link to comment https://forums.phpfreaks.com/topic/117907-load-list-of-urls/#findComment-606510 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? Link to comment https://forums.phpfreaks.com/topic/117907-load-list-of-urls/#findComment-606511 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 Link to comment https://forums.phpfreaks.com/topic/117907-load-list-of-urls/#findComment-606513 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 Link to comment https://forums.phpfreaks.com/topic/117907-load-list-of-urls/#findComment-606517 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. Link to comment https://forums.phpfreaks.com/topic/117907-load-list-of-urls/#findComment-607230 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.