[英]how to get the value of an input field by simple_html_dom
我想獲取輸入字段的值。 例如。 我的 HTML 中有這個輸入字段。 現在我用它來獲取 HTML DOM。
simple_html_dom.php
之后我嘗試這樣。 但無法獲得價值。
include_once('simple_html_dom.php');
$file_token = str_get_html($response);
$tokenid = $file_token->find('input#hash_9e879c117c');
echo $tokenid->value;
您是否嘗試過使用DOMElement :: getAttribute ?
$token = $doc->getElementById("hash_9e879c117c")->getAttribute("value")
嘗試使用:
$tokenid = $file_token->find('input#hash_9e879c117c', 0);
這給出了第一個元素而不是數組。
include "./simple_html_dom.php" ;
$html = file_get_html("https://example.com/login") ;
$token = $html->getElementByTagName("input[name=_token]")->getAttribute("value") ;
echo "token is : " $token ;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.