Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you know the name of the element and are truly only after one little thing and the format of the page is always the same, it might be less work to just use <code>curl</code> and <code>explode</code> to parse the document with string compares. This is a quick-and-dirty way to do it, but as long as those two conditions are met this is arguably the fastest way:</p> <pre><code>$url = 'http://example.com/'; $options = array( CURLOPT_RETURNTRANSFER =&gt; true, // return web page CURLOPT_HEADER =&gt; false, // don't return headers CURLOPT_FOLLOWLOCATION =&gt; true, // follow redirects CURLOPT_ENCODING =&gt; "", // handle all encodings CURLOPT_USERAGENT =&gt; "spider", // who am i CURLOPT_AUTOREFERER =&gt; true, // set referer on redirect CURLOPT_CONNECTTIMEOUT =&gt; 120, // timeout on connect CURLOPT_TIMEOUT =&gt; 120, // timeout on response CURLOPT_MAXREDIRS =&gt; 10 // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $parts = explode('&lt;input id="ID1" name="NAME1" value="', $content); if (count($parts) == 2) { $value = explode('"&gt;', $parts[1]); $value = $value[0]; } else { $value = false; } print 'Value is: ' . $value; </code></pre> <p>Otherwise, you could use regex (again using <code>curl</code> as above):</p> <pre><code>preg_match('/name="NAME1".+value="(.*?)"/i', $html, $value); $value = $value[1]; </code></pre> <p>Finally, if you want to go all-out on this one, you can use a document parser. Be warned, however, that if the HTML you are working with is not properly formed, the parser will have trouble. Here's a tutorial on the subject, using a third-party class: <a href="http://net.tutsplus.com/tutorials/php/html-parsing-and-screen-scraping-with-the-simple-html-dom-library/" rel="nofollow">http://net.tutsplus.com/tutorials/php/html-parsing-and-screen-scraping-with-the-simple-html-dom-library/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload