When I’m on my MacBook Pro, I use command line a lot. Either for casual task, or work related task. Sometimes, I need to access website to detect things while I’m doing my task in Terminal.app. Using curl or wget is inevitable.
But some websites are reluctant to show me the proper result, due to User-Agent blocking. This is common. But with simple modification, I can bypass that User-Agent limitation.
For wget, I created a file ~/.wgetrc under my home folder. Add these following lines:
user_agent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Safari/605.1.15 referer = https://www.google.com/search?client=safari&q=hacking robots = off
For curl, I created a file ~/.curlrc under my home folder. Add these following lines:
user-agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0.1 Safari/675.1.15"
Save those files, and test it by visiting https://ifconfig.io/ua
There!