Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does wttr.in respond differently to browsers than it does curl?

Tags:

browser

curl

If you go to http://wttr.in/ in your browser you'll see a page which is wrapped in a tag, has links, and is colored using spans.

If you then go to terminal and type curl http://wttr.in/ you'll get pretty much exactly the same looking page, but the code is very different.

How does wttr.in differentiate between these two?

I'm aware of this existing question (How can I tell a curl request vs browser request), but as the answer is "you can't" and I'm seeing proof you can, it seemed like a poor reference.

Also, I'm not worried about spoofing.

like image 476
Seph Reed Avatar asked Dec 02 '25 09:12

Seph Reed


1 Answers

Found it. The headers from a default curl contain

headers: { host: 'localhost:3000', 'user-agent': 'curl/7.54.0', accept: '/' },

While the headers from my browser are like so:

headers: { host: 'localhost:3000', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:62.0) Gecko/20100101 Firefox/62.0', accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'accept-language': 'en-US,en;q=0.5', 'accept-encoding': 'gzip, deflate', connection: 'keep-alive', 'upgrade-insecure-requests': '1', 'cache-control': 'max-age=0' },

The big difference between the two being the "user-agent" argument

like image 177
Seph Reed Avatar answered Dec 07 '25 01:12

Seph Reed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!