Jump to content

Script runs slow but plenty of memory on server


youneek

Recommended Posts

Can anyone help me figure out how to make this script run faster?

 

<?
if (!isset($domains)){
?>
<form method="post" action="">
<textarea name="domains" rows="10" cols="30"></textarea><br />
<input type="submit" value="Send">
</form>
<?
}else{
$domains = explode("\n", $_POST['domains']);
foreach ( $domains as $addr ){
$url = "http://web.archive.org/web/*/http://".trim($addr, "\r");
$data = implode("", file($url));
preg_match_all ("/<p class=\"mainSearchTitle\">([^`]*?)<\/p>/", $data, $matches);
	foreach ($matches[0] as $match) {
	$match = strip_tags($match);
	echo trim(preg_replace("/ pages found for/", "", $match), "             ")."<br />";
	flush();
    	ob_flush();
	}
}
}
?>

Since it's a remote file (or it looks like one) your script has to retrieve it and so on.... Plus, the server at the other end could be the slow one, or even if it's not slow, if your script is making a lot of requests to it, it could be slightly lagging a little.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.