网站不接受wget用户代理标头

编程入门 行业动态 更新时间:2024-10-26 08:32:45
本文介绍了网站不接受wget用户代理标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我运行此命令时:

wget --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0" yahoo

...我得到了这个结果(文件中没有其他内容):

...I get this result (with nothing else in the file):

<!-- hw147.fp.gq1.yahoo uncompressed/chunked Wed Jun 19 03:42:44 UTC 2013 -->

但是当我运行 wget yahoo 没有 - user-agent 选项,我得到整页。

But when I run wget yahoo with no --user-agent option, I get the full page.

用户代理是我当前浏览器发送的标题。为什么会这样?有没有办法确保用户代理在使用wget时不被阻止?

The user agent is the same header that my current browser sends. Why does this happen? Is there a way to make sure the user agent doesn't get blocked when using wget?

推荐答案

雅虎服务器似乎做了一些基于用户代理的启发式<接受标头设置为 * / * 。

It seems Yahoo server does some heuristic based on User-Agent in a case Accept header is set to */*.

接受:text / html

Accept: text/html

为我做了诀窍。

例如

wget --header="Accept: text/html" --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0" yahoo

注意:如果你没有声明接受标题,那么 wget 自动添加接受:* / * 这意味着给我任何东西。

Note: if you don't declare Accept header then wget automatically adds Accept:*/* which means give me anything you have.

更多推荐

网站不接受wget用户代理标头

本文发布于:2023-11-10 10:36:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575124.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不接受   用户   网站   wget

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!