New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP]Use useragent module to keep it updated #6444
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/diy/rsshub/nenxcnuxz |
I think we can implement a default UA in the middleware. In config we can have |
There's already a
It's more than that. Some require Windows/MacOS/Android/iOS, and others require Chrome/Webkit/Firefox. Enumerate all of them will be equavelant to reinventing the |
I guess what I was trying to say was, creating a Lines 33 to 35 in 0be537f
In routes it will be convenient with the helper: const response = await got({
url,
method: 'get',
headers: {
'User-Agent': UAHelper('chrome','desktop'),
},
}); |
Sure. But I don't see many differences than const response = await got({
url,
method: 'get',
headers: {
'User-Agent': (new UserAgent([
/Chrome/,
{
deviceCategory: 'desktop',
},
])).toString(),
},
}); |
const UA = require('@/utils/user-agent');
const response = await got({
url,
method: 'get',
headers: {
'User-Agent': UA.get('chrome','desktop'),
},
}); Where Sorry I'm too busy to respond swiftly, multiple deadlines... |
You are awesome For the problem, I'm convinced. I think a wrapper will make it cleaner, although there's no performance improvement (each time you still have to initialize a UserAgent instance). Just concerning about whether it would be type hinting unfriendly (especially useful in IDEs) as the got wrapper. Maybe there are some way to not have this drawback. Will look into it tomorrow. |
|
The random UA json is outdated with iOS 11 as the latest... |
yes... Still looking for a module with an up-to-date database.. |
I think we could still have it, and wrap a little bit in case we need to switch to other package. It will definitely better than our existing one. Please advise. |
Superseded by #9449 |
该 PR 相关 Issue / Involved issue
Some hard-code useragents are so old that became rare for real users. Relying on modules is more sustainable to keep up with top browser fingerprints.