phantomjs icon indicating copy to clipboard operation
phantomjs copied to clipboard

PhantomJS returns no real results.

Open dall opened this issue 13 years ago • 1 comments

Hello, I did a very small test:

var page = require('webpage').create()
  , fs   = require('fs');

page.open("http://www.google.it/search?q=web+design", function(status){

    if (status === 'success')
    {
        page.render('google.png');
        fs.write("source.html", page.content, 'w'); 
    }

    phantom.exit(); 
})

As you can see I search "web design" on google.it

Now, looking the source.html I noticed differences between PhantomJS generated source code and the real (Element Inspector of Chrome) html.

In my source code a result has this code:

`

  • WebDesign - Guide e approfondimenti per webdesigner - HTML.it

    www.html.it/web-design/ - Copia cache
    WebDesign: progettazione Web, User Experience, Architettura dell'informazione,
    i consigli di esperti designer in guide e articoli di approfondimento in italiano.

  • `

    BUT the real source (read via Element Inspect of Chrome) is:

    `

  • WebDesign - Guide e approfondimenti per webdesigner - HTML.it

    www.html.it/web-design/‎
    WebDesign: progettazione Web, User Experience, Architettura dell'informazione, i consigli di esperti designer in guide e articoli di approfondimento in italiano.
  • ` as you can see the last code is more complete.

    Why those results have different code?

    I read PhantomJS executes all the JS Inside the page as I browser does, so why those differences?

    dall avatar Jul 07 '13 13:07 dall

    Not a bug. Please search the mailing list, this has been answered many times before: (1) you need to wait for the JS to execute, and (2) some sites serve different data depending on the browser requesting it, so change the userAgent string if you care about that.

    JamesMGreene avatar Jul 07 '13 13:07 JamesMGreene