擅长:python、mysql、java
<p>您试图打开的URL是gzip的(使用<a href="http://checkgzipcompression.com/" rel="nofollow">this link</a>检查),因此您必须将<code>gzip</code>的<code>Accept-Encoding</code>头附加到<code>Browser</code>中:</p>
<pre><code>import mechanize
br = mechanize.Browser()
br.set_handle_robots(False)
br.addheaders = [('User-agent', 'Firefox')]
br.addheaders.append( ['Accept-Encoding','gzip'] )
br.open("http://dining.ut.ac.ir/")
br.forms()
</code></pre>