我正在尝试使用goutte从html文件中提取特定值
$client = new Client();
$crawler = $client->request('GET', 'http://localhost:8081/app_dev.php');
$htmlContent= $crawler->filter('label')->last()->html();
var_dump($htmlContent);die();
在这种情况下,我得到了摘录:
<input type="password" maxlength="40" myfield1="KqewkKAFyk7Vmsy" >
我想提取a的值myfield1
。我该如何实现?
我尝试了allready,但没有成功(结果为NULL):
$htmlContent= $crawler->filter('label')->last()->attr('myfield1');
您的代码尝试过滤,label
而不是input.
这应该工作(假设这是最后一个输入):
$htmlContent = $crawler->filter('input')->last()->attr('myfield1');
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句