我正在尝试在网站上提交表单,但提交表单的方式似乎被一些javascript所取代。试图找到http请求实际发送到的位置一直是一个真正的痛苦。我很难获得所需的实际网址。通常我只会使用 cURL 来创建发布请求。有没有办法使用 PHP 在网站上模拟按钮按下或运行 javascript?或者我可以使用任何工具来以某种方式窥探表单提交到的实际 URL?
编辑我没有任何代码要发布,因为我不知道从哪里开始解决这个问题。由于我没有发出发布请求的 url,因此我这样做毫无意义:
$url = 'https://id.oculus.com/US/en-US/login/';
$data = array('email' => 'bla', 'password' => 'things');
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded'r'n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }
是的,Javascript可以模拟按钮按下,PHP可以回显Javascript。
只需使用类似以下内容:
"echo 'document.getElementById("id_of_button").click();';"
这将模拟按下 ID 为"id_of_button"的按钮
如果这不是你需要的,那么如果你还没有,试着对Javascript进行去混淆,然后尝试分析它,试图找出发生了什么。
希望这有所帮助!
这是我的第二个答案!
最好的问候, -gauched