wttr.in对浏览器的响应与卷曲相比有何不同? [英] How does wttr.in respond differently to browsers than it does curl?
问题描述
如果您在浏览器中转到 http://wttr.in/ ,则会看到一个页面,其中
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.
如果然后转到终端并输入 curl http:// wttr .in /
您会看到几乎完全相同的页面,但是代码却大不相同。
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.
wttr.in有何区别这两个之间?
How does wttr.in differentiate between these two?
我知道这个现有问题(如何分辨curl请求与浏览器请求),但答案是你做不到,我正在证明你可以,这似乎是一个不好的参考。
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.
推荐答案
找到了。默认卷曲的标题包含
Found it. The headers from a default curl contain
标题:
{主机:'localhost:3000',
'user -agent': curl / 7.54.0,
接受:' / '},
虽然我的浏览器中的标头是这样的:
While the headers from my browser are like so:
标头:
{主机:'localhost:3000',
'user-agent':'Mozilla / 5.0(Macintosh; Intel Mac OS X 10.13; rv:62.0)Gecko / 20100101 Firefox / 62.0',
接受:'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',
连接:'keep-alive',
'upgrade-insecure-requests':'1',
'cache-control': 'max-age = 0'},
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
这篇关于wttr.in对浏览器的响应与卷曲相比有何不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!