How do I set User-Agent?

Showing 1-6 of 6 messages
How do I set User-Agent? Colin Steele 9/30/10 1:26 PM
I'm using envjs/rhino to scrape as if the server side is a client, but
the User-Agent HTTP header is showing up weird, and I think the server
is sending back SEO-optimized pages.  I'd like envjs to act like a
"real" browser...  Anyhow, here's a simple test:

$ nc -lp 3333
GET / HTTP/1.1
User-Agent: Java/1.6.0_20
Host: localhost:3333
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive

^L^C punt!


And as you can see it's coming across as Java/1.6.0_20.  How do I set
that?  I've tried:

Envjs({
    'appCodeName': 'Mozilla',
    'appName': 'Netscape',
    'appVersion': '5.0 (Macintosh; en-US)',
    'language': 'en-US',
    'mimeTypes': [],
    'platform': 'MacIntel',
    'oscpu': 'Intel Mac OS X 10.6',
    'vendor': '',
    'vendorSub': '',
    'product': 'Gecko',
    'productSub': '20100115',
    'plugins': [],
    'securityPolicy': '',
    'userAgent': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-
US; rv:1.9.2) Gecko/20100115 Firefox/3.6',
    'cookieEnabled': true,
    'onLine': true,
    'buildID': '20100115132715',
    'javaEnabled': function() { return false; }
});

Any help is much appreciated!

Re: [env-js] How do I set User-Agent? Thatcher 10/4/10 8:42 AM
Can you try

window.navigator.userAgent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6';

I'm surprised to see what user agent is reported.  you should see the user agent as part off the start up of Envjs.  Normally this is

Envjs/1.6 (Rhino; U; Mac OS X x86_64 10.5.8; en-US; rv:1.7.0.rc2) Resig/20070309 PilotFish/1.2.0.XX

where XX is the Envjs build number.  Do you see this when you start up envjs?

Thatcher


--
You received this message because you are subscribed to the Google Groups "Env.js" group.
To post to this group, send email to en...@googlegroups.com.
To unsubscribe from this group, send email to envjs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/envjs?hl=en.




--
Christopher Thatcher
Re: How do I set User-Agent? Colin Steele 10/4/10 12:28 PM
Hmm.  Here's what I get:

java.util.concurrent.ExecutionException:
org.mozilla.javascript.EcmaError: TypeError: Cannot set property
userAgent that has only a getter.

(I'm running envjs/rhino embedded, from java land.)

On Oct 4, 11:42 am, chris thatcher <thatcher.christop...@gmail.com>
wrote:
> Can you try
>
> window.navigator.userAgent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X
> 10.6; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6';
>
> I'm surprised to see what user agent is reported.  you should see the user
> agent as part off the start up of Envjs.  Normally this is
>
> Envjs/1.6 (Rhino; U; Mac OS X x86_64 10.5.8; en-US; rv:1.7.0.rc2)
> Resig/20070309 PilotFish/1.2.0.XX
>
> where XX is the Envjs build number.  Do you see this when you start up
> envjs?
>
> Thatcher
>
> On Thu, Sep 30, 2010 at 4:26 PM, Colin Steele <cvillecste...@gmail.com>wrote:
> > envjs+un...@googlegroups.com <envjs%2Bu...@googlegroups.com>.
Re: How do I set User-Agent? Colin Steele 10/4/10 12:29 PM
Sorry, and yes, this is what I see at startup:


[  Envjs/1.6 (Rhino; U; Mac OS X x86_64 10.5.8; en-US; rv:1.7.0.rc2)
Resig/20070309 PilotFish/1.2.13  ]



On Oct 4, 11:42 am, chris thatcher <thatcher.christop...@gmail.com>
wrote:
> Can you try
>
> window.navigator.userAgent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X
> 10.6; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6';
>
> I'm surprised to see what user agent is reported.  you should see the user
> agent as part off the start up of Envjs.  Normally this is
>
> Envjs/1.6 (Rhino; U; Mac OS X x86_64 10.5.8; en-US; rv:1.7.0.rc2)
> Resig/20070309 PilotFish/1.2.0.XX
>
> where XX is the Envjs build number.  Do you see this when you start up
> envjs?
>
> Thatcher
>
> On Thu, Sep 30, 2010 at 4:26 PM, Colin Steele <cvillecste...@gmail.com>wrote:
> > envjs+un...@googlegroups.com <envjs%2Bu...@googlegroups.com>.
Re: [env-js] Re: How do I set User-Agent? Thatcher 10/4/10 12:56 PM
Ah, can you try a more recent build?  If you have ant and the project from github you should be able to run "ant zip" to get a fresh build in dist/env.rhino.js.  We added a setter for window.navigator.userAgent and fixed a couple bugs in navigator as well.  Let me know if this helps.

Thatcher

To unsubscribe from this group, send email to envjs+un...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/envjs?hl=en.




--
Christopher Thatcher
Re: [env-js] Re: How do I set User-Agent? Colin Steele 10/4/10 1:23 PM
Bingo!  Thanks very much!Colin Steele
CTO, hotelicopter

w: (434) 227-4513
t: @cvillecsteele
I've got the dreamer's disease.