deed02392 Posted May 27, 2008 Share Posted May 27, 2008 I want to extract rapidshare.com links from a bunch of text that gets submitted from a textarea. http://pastebin.com/m23119236 So far I've made it so it removes the extension .html so my download manager can download the file and not the page rapidshare redirects me to. I read quite a bit into it and I think the key is regexp function, but I'm not sure how to implement it so that it ONLY will print the result including the link http://rapidshare.com/* or http://www.rapidshare.com/*. Thanks in advanced! Link to comment https://forums.phpfreaks.com/topic/107500-solved-link-extractor-from-textarea-not-a-website/ Share on other sites More sharing options...
deed02392 Posted May 28, 2008 Author Share Posted May 28, 2008 Does no one have any idea on how I could achieve this? Link to comment https://forums.phpfreaks.com/topic/107500-solved-link-extractor-from-textarea-not-a-website/#findComment-551642 Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 give me an example of the input a user can/will submit, so I have an idea how to go about doing this. do they just insert the link, or a whole load of data? Link to comment https://forums.phpfreaks.com/topic/107500-solved-link-extractor-from-textarea-not-a-website/#findComment-551647 Share on other sites More sharing options...
deed02392 Posted May 28, 2008 Author Share Posted May 28, 2008 give me an example of the input a user can/will submit, so I have an idea how to go about doing this. do they just insert the link, or a whole load of data? http://www.georgehafiz.co.uk/linkfilter.php In here, you would post a big bunch of text, for example: Backup 1: http://rapidshare.com/files/##### http://rapidshare.com/files/##### http://rapidshare.com/files/##### http://rapidshare.com/files/##### http://rapidshare.com/files/##### Backup 2: http://rapidshare.com/files/##### http://rapidshare.com/files/##### http://rapidshare.com/files/#####http://rapidshare.com/files/##### This would all get cleaned up to just show the rapidshare links on line breaks. So far my script just removes any .html extension to the file so I can download directly the file from the page, instead of going to the html page where it then pops up... I'd now also like to be able to remove anything that ISN'T a rapidshare link, and the echo them on lines. I was thinking something like explode() and then removing any entry in the array that wasn't a link but for that I need regexp and I have no idea how to do this, it's a bit too complicated. If you could give me a quick example I will be able to pick it apart and learn it, that's the way I learn :-\ Link to comment https://forums.phpfreaks.com/topic/107500-solved-link-extractor-from-textarea-not-a-website/#findComment-551651 Share on other sites More sharing options...
jonsjava Posted May 28, 2008 Share Posted May 28, 2008 this should do it for you: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Rapidshare Link Filter</title> <?php //vars $oldText = $_POST['tofilter']; $array = explode("\n", $oldText); $result = ""; foreach ($array as $value){ if (strstr($value, "http")){ $result .= str_replace(".html", "", $value)."<br />"; } } ?> </head> <body> <?php if ($oldText) { echo "Filtered result:<br />"; echo $result; echo "<br />"; echo "<a href='javascript:history.go(-1)'>Go again</a>"; } else { echo '<form method="post" action="linkfilter.php"> <b>Enter data to filter:</b><br /> <textarea name="tofilter" wrap="virtual" rows="20" cols="100">'; $oldText; echo '</textarea> <br /><input type="submit" name="submit" value="Submit" /> </form> <br /> '; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/107500-solved-link-extractor-from-textarea-not-a-website/#findComment-551668 Share on other sites More sharing options...
deed02392 Posted May 28, 2008 Author Share Posted May 28, 2008 It works perfectly, thanks a lot. I now need to pick it apart and see what happens. Thanks. Link to comment https://forums.phpfreaks.com/topic/107500-solved-link-extractor-from-textarea-not-a-website/#findComment-551683 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.