php - 在循环中重定向到自我页面并处理数据
问题描述
我正在处理来自外部页面的一些数据。页面可以按顺序访问,即http://localhost/info/1.html , http://localhost/info/2.html , http://localhost/info/3.html , ....
<?php
$id = 0;
$id = intval($_GET['id'])+1;
$url = 'http://localhost/info/'.$id.'.html';
if (!$html = @file_get_contents($url)) {
$url = 'http://localhost/crawler.php?id='.$id;
//header("Location: ".$url);
echo '<html><script>window.location.href = "'.$url.'";</script> </html>';
die();
}
//process data
$url = 'http://localhost/crawler.php?id='.$id;
//header("Location: ".$url);
echo '<html><script>window.location.href = "'.$url.'";</script></html>';
die();
?>
问题是 PHP 重定向停止显示错误页面未正确重定向,并且使用 JavaScript 重定向看起来更慢。已经尝试使用标头删除回声。
**
有什么方法可以加快这个过程吗?
**
解决方案
推荐阅读
- python - 通过在 Anaconda 上使用 pandas,运行超过 1,000,000 行的 DataFrame 的数据透视表很慢。有什么提高效率的建议吗?
- azure - 查找未使用的存储帐户 azure ARM
- macos - 无法从 Docker 容器访问外部数据库
- python - pd.df 的自定义分组,以矢量化方式计算 OHLC
- python - 映射两个熊猫数据框并向第一个数据框添加一列
- xpath - XPATH returning nothing
- javascript - 我们如何调整此代码以防止打开新浏览器选项卡的操作执行名为“fetchRecommendations”的函数?
- javascript - 如何在Angular中将当前时间转换为CET
- pandas - 使用 pandas 数据框值运行复杂函数的总和
- flutter - 关闭应用程序时如何关闭所有通知?