Frage

How to get a form with specific name using phpQuery?

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

My try:

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");
War es hilfreich?

Lösung

Use this...

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

Source.

Andere Tipps

phpQuery supports same CSS/jQuery like selectors, so this is what you want:

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

Note: Also change $pq->find to pq

Example:

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

Result:

Something

In your case through, it will return form's html.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top