删除或隐藏从网址中刮取的文本

发布于 2024-11-29 04:19:00 字数 1469 浏览 1 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拧巴小姐 2024-12-06 04:19:00

对于每一行:

$row = preg_replace( '/(?:\-|\b)\d{1,4}.\d{1}\b(?=.*distance)/', '#', $row );

完整代码:

$contents = file_get_contents('http://dreamphreak.com/pwn9/yasmp/nocheat.php');
$rows = explode( "\n", $contents );
$new_contents = '';
foreach ( $rows as $row ) {
    $row = preg_replace( '/(?:\-|\b)\d{1,4}.\d{1}\b(?=.*distance)/', '#', $row );
    $new_contents .= $row."<br> ";
}

echo $new_contents;

For each row:

$row = preg_replace( '/(?:\-|\b)\d{1,4}.\d{1}\b(?=.*distance)/', '#', $row );

Complete code:

$contents = file_get_contents('http://dreamphreak.com/pwn9/yasmp/nocheat.php');
$rows = explode( "\n", $contents );
$new_contents = '';
foreach ( $rows as $row ) {
    $row = preg_replace( '/(?:\-|\b)\d{1,4}.\d{1}\b(?=.*distance)/', '#', $row );
    $new_contents .= $row."<br> ";
}

echo $new_contents;
千紇 2024-12-06 04:19:00

这不是更容易吗?

$contents = file_get_contents('http://dreamphreak.com/pwn9/yasmp/nocheat.php');
$contents = preg_replace( '/\([0-9\.,\- ]+\) to \([0-9\.,\- ]+\)/', '', $contents );

echo $contents;

在我的网络服务器上工作

当使用“Nobody”给您的代码时,您遇到页面无法加载的问题的原因是您达到了服务器的最大页面执行时间。它可以处理小数据样本,因为它可以在 30 秒内完成(或者无论你的服务器的最大执行时间是多少。我的是 30),但大量的实时数据处理时间太长。

我尝试对两者进行速度比较,但由于超时,我也无法让其他解决方案工作。相反,我从您的实时数据中抽取了 40 行样本,并使用该样本对两种解决方案进行了速度测试。

我的解决方案在 10 次运行中平均耗时 0.0001 秒
没有人的解决方案在 10 次运行中平均耗时 0.0007 秒,

我建议找到一种方法来完成整个任务,而不必单独循环每一行。

Wouldn't this be easier?

$contents = file_get_contents('http://dreamphreak.com/pwn9/yasmp/nocheat.php');
$contents = preg_replace( '/\([0-9\.,\- ]+\) to \([0-9\.,\- ]+\)/', '', $contents );

echo $contents;

Working on my web server.

The reason you were having trouble with the page not loading when using the code that 'Nobody' gave you is that you're hitting the maximum page execution time for your server. It worked with a small sample of data because it can do that in under 30 seconds (or whatever your server's max execution time is. Mine is 30), but the huge piece of live data is taking it too long to process.

I tried doing a speed comparison between the two but I also couldn't get the other solution to work due to the timeout. Instead I took a sample of 40 lines from your live data and ran a speed test on both solutions using that.

My solution averaged 0.0001 seconds in 10 runs
Nobody's solution averaged 0.0007 seconds in 10 runs

I'd suggest finding a way to do the whole thing without having to individually loop over each line.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文