I have a bunch of URLs. Each one redirects several times. I need to find out what are the destination URLs of all of those URLs. I'd like them to be shown as a list or smth like that. I've searched through stackoverflow and only found a couple of scripts that does it but unfortunately for only one URL. Does anyone by chance have a piece of php or java code that can do it? I'm almost complete zero in php.
Asked
Active
Viewed 204 times
0
-
Use the script you found for each URL in a loop? – Ezzored Nov 07 '13 at 21:58
-
1Thanks, but I dont know how to do it. Here is the script I've found: – derek Nov 07 '13 at 22:02
-
$ch = curl_init("http://mylink.com"); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); $data = curl_getinfo($ch); echo $data["url"]; – derek Nov 07 '13 at 22:07
-
Use a foreach construct: http://us3.php.net/manual/en/control-structures.foreach.php Or just forget PHP if you are "zero" in it, and find a JAVA solution: http://stackoverflow.com/questions/2659000/java-how-to-find-the-redirected-url-of-a-url – Ezzored Nov 07 '13 at 22:09
-
Thanks for the tip, I've just tried using foreach and managed to echo urls from the array but they are printed on the page inline. Do you know how i can echo them so they are printed one under one? – derek Nov 07 '13 at 22:33
-
Nevermind, found out how to do that too. :) Thank you very much for your help. – derek Nov 07 '13 at 22:35