Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要单击使用 loadHTMLFile 加载的远程页面中的按钮,就像在 javascript 中一样。有可能的?就像是:
$domObject->getElementById('clickableButton')->click();
谢谢!
当您在 DOM 中加载页面时,它只是一堆分成对象的字符串。所以答案是否定的——PHP 中的 DOM 无法解析和运行 javascript 代码。
但是,如果您尝试提交表单,您可以向表单元素的 action 属性中给出的 URL 发出 GET/POST 请求。尝试使用 cURL,或者只是file_get_contents可以做到这一点。
file_get_contents