question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot set user agent

See original GitHub issue

How do I override the user agent? I have tried the following;

const stealthPlugin = require('puppeteer-extra-plugin-stealth')();
stealthPlugin.enabledEvasions['user-agent-override'] = 'Cool Agent';
puppeteer.use(stealthPlugin);

However when I navigate to https://bot.sannysoft.com/ I can see the user agent is unchanged.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
berstendcommented, Sep 27, 2020

PS: I’m working on a better/unified way to override stealth plugin settings in #303

0reactions
kekearifcommented, Oct 1, 2020

@berstend Thanks for this. Sorry for the late reply. I’m curious what exactly is locale? Do these languages have to match the browser languages set by puppeteer? For example if I go to https://bot.sannysoft.com it will say my languages are en-US,en. Are these the values I should use? What is q=0.9?

This is a user agent I found Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36, how would I construct the object for this?

const ua = UserAgentOverride({
  userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.3',
  locale: 'en-US,en;q=0.9',
  // Is this right for the platform?
  platform: 'macOS'
})

I’m not sure if my example above is correct or not.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Change User-Agents in Chrome, Edge, Safari & Firefox
In Firefox, it is possible to change user-agents via the browser's built-in settings. However, it is not as user-friendly as on Chrome or ......
Read more >
Can't set User-Agent · Issue #157 · rakyll/hey - GitHub
I can`t set User-Agent with -H.
Read more >
Cannot include user-agent into my headers - Stack Overflow
Use the HttpRequestHeader.UserAgent instead of a string "User-Agent ". That'll fix it.
Read more >
User-Agent - HTTP - MDN Web Docs - Mozilla
The User-Agent request header is a characteristic string that lets servers and network peers identify the application, operating system, ...
Read more >
How to Change User-Agent in Chrome, Firefox, Safari, and more
Change user -agent from Inspect element window. ... For demonstration, I am going to use Chrome. You can follow the exact same instructions...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found