I am testing some code that gets the content of Google Base page:

$googleDetailContent=file_get_contents("http://www.google.com/base/a/1372710/D17473680841346550802");

Going through the browser, the above url displays a Buy button, along with pricing information. But when I echo $googleDetailContent, Buy button html is not part of the string.

How is Google blocking certain elements from file_get_contents?

    well usually if they have fopen wrappers disabled, you cannot get ANY of the file...although that button may be an include? did you see any code like that...

      I do not think that the PHP settings on their side matters. file_get_contents() should just read all of the clientside output of that page.

        I tried that code and got everything (unless there's something after the </html> tag beyond a couple of spaces).

        But of course it's not going to work without the Javascript. The CSS might help as well.

          Weedpacket, you'll have to check what you got back from file_get_contents against the actual source rendered by the browser. That's when I noticed Google has somehow blocked me from getting the Buy link and pricing info.

          The javascript and css do come over with file_get_contents.

            css doesn't come over, if the style sheet is linked, then it screws up the relative path during the function

              You may find Google serving different content to you depending on what User-Agent header you send (e.g. if you're a browser or not).

                Write a Reply...