擅长:python、mysql、java
<p>我想原因是url不支持robot访问站点。您需要通过发送浏览器标题和请求来伪造浏览器访问</p>
<pre><code>import urllib.request
url = "http://lebed.com/"
req = urllib.request.Request(
url,
data=None,
headers={
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'
}
)
f = urllib.request.urlopen(req)
</code></pre>
<p>在我的系统上试过这个,效果很好。在</p>