TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Do you set the user-agent on your scripts?

3 pointsby kfdmalmost 4 years ago
Typically I try to remember to set the user-agent on tools&#x2F;scripts I make, to avoid default agents like `Go-http-client&#x2F;version` or `python-request&#x2F;version` but it seems like a lot of projects do not always set it.<p>Sometimes I will submit patches to projects to fix this, though sometimes I wonder if I&#x27;m in the minority of developers who prefer to properly set user-agent.<p>(I am fully aware and agree that the user-agent for most web browsers is terribly complicated and almost useless at this point. My focus is more on bots&#x2F;scrapers&#x2F;etc)

2 comments

pitchedalmost 4 years ago
There’s a dev-time vs. reliability debate here, I think. I don’t think it’s worth worrying about most of the time but I would approve a PR if someone did do the work.<p>When scripting things that probably shouldn’t be scripted but I care about them (like covid stuff), I’ll take the time to find a good browser user agent. I would be worried about bot-prevention measures catching a non-standard user agent and taking it down. Or even worse, someone else made a terrible script posting dos-level traffic and mine gets banned along with it...<p>The next level is using a custom but specific-to-the-script user agent. I do this whenever I also own the backend, to make tracking down logs way easier.<p>For everything else, I use the default! In this case, taking the extra time to think of an appropriate user agent isn’t helpful to the project. Sometimes, I might still send up Star Wars references for fun.
alexeldeibalmost 4 years ago
Production-grade software: yes.<p>Hobby: not always.<p>It’s incredibly useful, IMO. Not everyone knows about it, or strictly needs it. But I think it’s very useful.<p>In Go, I often find a lower level SDK-type library will let you append to the user agent, which for large web services is nice since you can basically see how all your callers are using your API (in my case usually looking at volume of calls from language SDKs vs raw HTTP calls vs CLI vs 3rd party tools)