Hi guys,
I'm trying to set the Accept-Language header, but its not working for me.... :(
My code:
var casper =require('casper').create(); casper.start();
casper.on('started', function () { headers: { "Accept-Language": "de-CH" } });
casper.thenOpen('http://casperjs.org', function() { this.echo(this.getHTML()); });
casper.run();
|
I'm using following versions:
Phantomjs: 2.1.1
Casperjs: 1.1.4
I'm getting this error:
SyntaxError: Unexpected token ':'
phantomjs://code/branding.js:8 in injectJs
If I run the script with node:
"Accept-Language": "de-CH"
^
SyntaxError: Unexpected token :
When I add
method: 'get',
before
"headers:"
^
the error will be thrown at the headers colon.
The Doc for "header":
http://docs.casperjs.org/en/latest/modules/casper.html#openI've also tried (no errors given):
casper.page.customHeaders = {
'Accept-Language': 'de-CH'
};
Also:
customHeaders:
{
"Accept-Language": "de-CH"
}
And this:
var casper = require(‘casper’).create(
{
pageSettings: {
customHeaders: {
"Accept-Language": "de-CH"
}
}
});
... also only with "header:"
I tried every snippet with this additional colon:
"Accept-Language:": "de-CH"
^
But the result I scrape is always:
en,*
When browsing normal with latest Firefox, Chrome or Edge, everything is fine. This is the PHP Code:
<?php echo $_SERVER['HTTP_ACCEPT_LANGUAGE'];
I cant set any headers, but useragent. Any ideas?
Thanks