Get Element By id or Name in Curl

curl, element, php

Solution

You'll have to use a DOM parser. Lately I've been using Query Path: http://querypath.org/

qp($result)->find('[name="name"]');

Problem

My target site contains code like this ``` <form> <input type="text" name="suggest" value="www.google.com"> <input type="submit" value="submit"> </form> ``` I Get this page with Curl Php ``` <?php $url="http://mysite.com"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); $result = curl_exec ($ch); echo $result; curl_close($ch); ?> ``` How can I get an element value using id or name? For example "www.google.com" in input name="suggest". Thanks for helping me. I cant use this code for remote like this : ``` <?php require 'Path/QueryPath.php'; qp('http://hipfile.com/bbgfom5ej9tm/zakhme_shaneie_haava_dvdrip.wmv.html/')- ``` find('[password="login"]')->writeHTML(); ?> and return this error Fatal error: Uncaught exception 'QueryPathParseException' with message 'DOMDocument::load() [domdocument.load]: AttValue: " or ' expected in http://hipfile.com/bbgfom5ej9tm/zakhme_shaneie_haava_dvdrip.wmv.html/, line: 18 (C:\xampplite\htdocs\test1\Path\QueryPath.php: 2106)' in C:\xampplite\htdocs\test1\Path\QueryPath.php:2346 Stack trace: #0 [internal function]: QueryPathParseException::initializeFromError(2, 'DOMDocument::lo...', 'C:\xampplite\ht...', 2106, Array) #1 C:\xampplite\htdocs\test1\Path\QueryPath.php(2106): DOMDocument->load('http://hipfile....', 0) #2 C:\xampplite\htdocs\test1\Path\QueryPath.php(179): QueryPath->parseXMLFile('http://hipfile....', NULL, NULL) #3 C:\xampplite\htdocs\test1\Path\QueryPath.php(23): QueryPath->__construct('http://hipfile....', NULL, Array) #4 C:\xampplite\htdocs\test1\index.php(3): qp('http://hipfile....') #5 {main} thrown in C:\xampplite\htdocs\test1\Path\QueryPath.php on line 2346 Can help me? I used two DOM And simplehtmldom but not working for me . it works for local page only.

Original source