我想通过 Guzzle 远程连接到一个特定的站点。用户名和密码字段没有名称的问题。
我的问题是:
我可以在不知道字段名称的情况下使用 POST 方法吗?
我可以改用班级的名称吗?
我的代码:
登录.php
<?php
require("master/guzzle/vendor/autoload.php");
$username = "abc";
$password = "123456";
$client = new \GuzzleHttp\Client();
$response = $client->post('https://www.exmaple.com/login', [
'body' => [
'username' => $username,
'password' => $password,
'action' => 'login'
],
'cookies' => true
]
);
echo $response;
?>
example.com/登录
<form>
<div class="login-name">
<div data-nep="Label" class="name-font default neptune_block_15yk4 neptune_LABEL-STANDARD_1h3i4">Username
<div class="neptune_fade-after_15yk4"></div>
</div>
<div data-nep="TextBox">
<input type="text" placeholder="" value="" class="neptune_default_1jbvk" style="height:30px">
</div>
</div>
<div class="login-name">
<div data-nep="Label" class="name-font default neptune_block_15yk4 neptune_LABEL-STANDARD_1h3i4">Password
<div class="neptune_fade-after_15yk4"></div>
</div>
<div data-nep="TextBox">
<input type="password" placeholder="" value="" class="neptune_default_1jbvk" style="height:30px">
</div>
</div>
</form>