ulixee / hero

The web browser built for scraping
MIT License
647 stars 32 forks source link

how to change user-agent in code? #247

Closed tsung-sc closed 5 months ago

tsung-sc commented 5 months ago

i've installed @ulixee/real-user-agents、@ulixee/chrome-104-0、@ulixee/chrome-105-0 and @ulixee/chrome-105-0,but i don't know how to use it.Can show me how to use it in code? i don't see any code in document! PLZ!

blakebyrnes commented 5 months ago

Did you come across this page? https://ulixee.org/docs/hero/advanced-client/user-agents

tsung-sc commented 5 months ago

Did you come across this page? https://ulixee.org/docs/hero/advanced-client/user-agents

yes,i've read it many times,but i still don't know how to change user-agent in every new Hero instance.there is no code to show me how to use the library above.

blakebyrnes commented 5 months ago

new Hero({ userAgent: '~ chrome >= 105 && windows >= 10' });

blakebyrnes commented 5 months ago

That example is with a specific os. You can remove it if you want it to round robin. Is it not working?

tsung-sc commented 5 months ago

That example is with a specific os. You can remove it if you want it to round robin. Is it not working?

I'm sorry that I didn't use this code again after installation, but it seems that the UA can be replaced now. But eventually I want to change the browser fingerprint. Is there any way?

blakebyrnes commented 5 months ago

That code will round robin between operating systems/versions and build versions of the chosen user agent. If you want to randomize the agent too, you can choose a range for your chrome versions

blakebyrnes commented 5 months ago

Just checking in. Did that answer your question?

tsung-sc commented 5 months ago

yes!thanks