Question: I'm trying to print the host/ip to the screen. But, it's printing: "Resource id #2" instead. I'm using SSH2\_connection(). I read the doc page and know the the function parameters are host, port, methods ... but when I try fread($host), the host/ip is still not printing can someone give me some direction on this? Thanks! 

Code:

```
 <?php
 if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
 if(!($ssh = ssh2_connect('10.5.32.12', 22))) {
     echo "fail: unable to establish connection\n"; 
 } else {

     if(!ssh2_auth_password($ssh, 'root', '********')) {
        echo "fail: unable to authenticate\n";
     } else {
         echo "Okay: Logged in  ... ";
         $content = fread($ssh); //Line in question (want ip address to show here)
         echo "$content <br>";        //Line in quesion
         $stream = ssh2_exec($ssh, 'find / -name *.log -o -name *.txt');   
         stream_set_blocking($stream, true);
         $data = '';
         while($buffer = fread($stream, 4096)) {
             $data .= $buffer;
         }
         fclose($stream);
         echo $data; // user
     }
 }
 ?>

```

Answer: 
You might be interested in checking out [pjscrape](http://nrabinowitz.github.com/pjscrape/) (disclaimer: this is my project). It's a command-line tool using [PhantomJS](http://code.google.com/p/phantomjs/) to allow scraping using JavaScript and jQuery in a full browser context - among other things, you can define a "ready" function for the page and wait to scrape until the function (which might check for the existence of certain DOM elements, etc) returns true.

The other option, depending on the page, is to use a console like Firebug to figure out what data is being loaded (i.e. what URLs are being retrieved by the AJAX calls on the page), and scrape the data directly from those URLs.
If the data are generated with javascript then the data are in the downloaded page. 
Better is to directly parse them on the fly as you do with plain HTML or Text parsing.
If you cannot isolate tokens with jSoup API just parse them using direct String options, as a plain text.