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

phpQuery はselectors のような同じ 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 に答える
2

これを使って...

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

ソース

于 2012-06-27T07:02:33.017 に答える