gpt4 book ai didi

php - Symfony 爬虫 selectButton 方法无法获取表单

转载 作者:搜寻专家 更新时间:2023-10-31 21:22:24 24 4
gpt4 key购买 nike

这是我的html

<form  name="station" method="post" action="/stations/new" role="form">
<div class="form-group">
<label class="control-label required" for="station_name">Name</label>
<input type="text" id="station_name" name="station[name]" required="required" maxlength="255" class="form-control" >
</div>
<div class="form-group">
<div class="checkbox">
<label for="station_active">
<input type="checkbox" id="station_active" name="station[active]" value="1" />Active</label>
</div>
</div>
<div class="form-group">
<button type="submit" id="station_submit" name="station[submit]" class="btn btn-primary">Ajouter</button>
</div>
<input type="hidden" id="station__token" name="station[_token]" class="form-control" value="aze123aze" >
</form>

我想使用抓取工具获取我的表单。我试过这样的 selectButton 方法

$form = $crawler->selectButton('station[submit]')->form(array());

但我收到错误:InvalidArgumentException: The current node list is empty.

问题是什么?

最佳答案

不幸的是,我没有足够的评分来写评论而不是将其放在答案中。

那么,您能否展示一下您是如何获得 $crawler 的?问题可能是:

  • $crawler 未指向包含此表单的 DOM

  • 此表单在某些 java 脚本操作(例如 Ajax)后出现在页面上,但不确定是否属于您的情况。

关于php - Symfony 爬虫 selectButton 方法无法获取表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43941703/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com