0

如何使用 phpQuery 获取具有特定名称的表单?

<form method="POST" name="example">
        <input type="hidden"
...

我的尝试:

include 'phpQuery-onefile.php';
//example site with this form
$html = file_get_contents("http://www.example.com");

$pq = phpQuery::newDocument($html);
$a = $pq->find("form name=example");
4

2 回答 2

2

用这个...

$a = $pq->find("form[name=example]");

来源

于 2012-06-27T07:02:33.017 回答
2

phpQuery 支持与选择器相同的 CSS/jQuery,所以这就是你想要的:

$a = pq("form[name=example]");

注意:$pq->find改为pq

例子:

phpQuery::newDocumentHTML('<form method="POST" name="example">Something</form>');
$a = pq("form[name=example]");
echo $a;

结果:

Something

在您的情况下,它将返回表单的 html。

于 2012-06-27T07:03:47.293 回答