2

I would like to get the files without headers. I have tried many things like

wget --header="" http://xxxxx.xxxxxx.xx

How can I get any files without headers?

nalply
  • 23,826
  • 12
  • 77
  • 96
ali
  • 21
  • 1
  • 2

3 Answers3

0

This doesn't quite answer the question, but I got here by looking up "remove default header wget" so I'll put in my 2 cents.

You can remove the User-Agent header with -U "". This was useful for me because the Geometry Dash servers will reject your request if it has a user agent.

-1

Could you assign the output of wget to a string, then use something else to process it to drop headers (or parse them out of the text)?

For example, using bash and grep, you can store the html from a webpage as a string, then use grep to extract the text in the <body> section:

w1=$(wget --quiet --output-document - www.example.com)
echo $w1 | grep --only-matching "<body>.*</body>"

which gives the output below (I have added some newlines to improve how it displays here):

<body> <div> 
<h1>Example Domain</h1> <p> 
This domain is established to be used for illustrative examples in documents.
You may use this domain in examples without prior coordination or asking for 
 permission.
</p> <p>
<a href="http://www.iana.org/domains/example">More information...</a></p> 
</div> </body>
dardisco
  • 4,896
  • 2
  • 37
  • 52
-2

‘--header=header-line’ Send header-line along with the rest of the headers in each http request. The supplied header is sent as-is, which means it must contain name and value separated by colon, and must not contain newlines. You may define more than one additional header by specifying ‘--header’ more than once.

      wget --header='Accept-Charset: iso-8859-2' \
           --header='Accept-Language: hr'        \
             http://fly.srk.fer.hr/ Specification

of an empty string as the header value will clear all previous user-defined headers.

As of Wget 1.10, this option can be used to override headers otherwise generated automatically. This example instructs Wget to connect to localhost, but to specify ‘foo.bar’ in the Host header:

      wget --header="Host: foo.bar" http://localhost/ In versions

of Wget prior to 1.10 such use of ‘--header’ caused sending of duplicate headers.

http://www.gnu.org/software/wget/manual/html_node/HTTP-Options.html

Ryan Guest
  • 5,679
  • 2
  • 31
  • 39
  • 2
    so how does this help @ali ? It looks like he/she has tried some stuff .. which means he/she knows about the --header option a bit .. but isn't getting any luck. Can u _remove_ any headers? (if that's what @ali is asking?) – Pure.Krome Oct 13 '10 at 13:04
  • Some headers must be included (in at least HTTP 1.1). For examples RFC 2616 states that the host header is one of the headers that must be included: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html – Ryan Guest Oct 13 '10 at 16:28
  • @RyanGuest (I know this comment is very old, but I'm adding information for future visitors) Yeah, but some aren't required. For example, in that very link, it says (emphasis not mine) "User agents SHOULD include [the User-Agent header] with requests." – TheTechRobo Stands for Ukraine May 12 '22 at 22:45