[英]How to save the value of a textbox to a .txt file using php in html without reloading or redirecting the page?
[英]How to save HTML file after redirecting the page
我试图在重定向到新的URL后保存HTML页面。 重定向工作正常,但重定向后似乎在我的PHP脚本中没有其他工作。
我正在使用CURL假装从浏览器运行,在该浏览器中我收到302错误以重定向到页面。 我需要做的就是在重定向后自动保存HTML页面内容。
欢迎任何建议。
$new_url = 'www.example.com';
$path = 'C:/page.html';
// redirect to new pages
header('Location:'. $new_url);
exit();
// load and save the file
$doc = new DOMDocument();
$doc->loadHTMLFile($new_url);
$doc->saveHTMLFile($path);
然后尝试在redirect
之前保存HTML
:
$new_url = 'www.example.com';
$path = 'C:/page.html';
// load and save the file
$doc = new DOMDocument();
$doc->loadHTMLFile($new_url);
$doc->saveHTMLFile($path);
// redirect to new pages
header('Location:'. $new_url);
exit();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.