How to get information hidden by javascript?

Kingfresh

Regular Member
Joined
Jul 8, 2009
Messages
369
Reaction score
297
Hey guys,

i need your help, i tried with java but didn't worked.... so i have a website that hides information behind a button (like a spolier) but it isnt a real spolier because it is text that you have click to ... like "Click me" than information is shown, anyway is there a solution to get this peace of information using php?

thanks!
 
You will need to use Javascript. I don't quite understand how PHP can help you in this case. PHP isn't really a "presentation" language.

If you want hidden elements. What you need to do is have their style (CSS style) set to "display:hidden". And then create an onclick event handler with javascript that does

getElementById('YourDivID').style.display="inline";

This will do just a straight show. There wont be any fancy fade effects or drop downs. But it works.

If you want straight Javascript on it. Check out something like this : http://dhtmlpopups.webarticles.org/fade-effects.php

Otherwise you can go have a look at other library's like jQuery etc.
 
If you want hidden elements. What you need to do is have their style (CSS style) set to "display:hidden". And then create an onclick event handler with javascript that does

I have something similar and that's exactly what I do.
 
If you want to write a script that scrapes the site, there could be a way.

If the javascript just "unhides" the information, you can parse the source and read whatever was being hidden.

On the otherhand if the JS makes an ajax call and inserts the reply into the page, you will have to parse the page source, grab the variables being sent via ajax, then make the xmlhttprequest in PHP.
 
Woah, OP, did you edit your post? Im 99% sure you never said that you didn't say scraping in the original post. You said you needed to hide content, Meh. Anyway...

For scraping content via PHP the easiest way will just be using CURL.

PHP:
<?php
        // create curl resource
        $ch = curl_init();

        // set url
        curl_setopt($ch, CURLOPT_URL, "example.com");

        //return the transfer as a string
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        // $output contains the output string
        $output = curl_exec($ch);

        // close curl resource to free up system resources
        curl_close($ch);     
?>

Stolen from http://www.php.net/manual/en/curl.examples-basic.php

There is better examples out there. But this does the basics. Generally speaking, Bozoclown is right. The spoiler will be in the source, and the button just shows it. Infact probably exactly how i explained in my first post.
 
Back
Top