擅长:python、mysql、java
<p>我在这里找到了一个可能的解决方案:</p>
<p><a href="http://www.mail-archive.com/pygtk@daa.com.au/msg18189.html" rel="nofollow">http://www.mail-archive.com/pygtk@daa.com.au/msg18189.html</a></p>
<p>基本上,它是关于使用urllib获取网站内容的,您可以在其中设置一个用户代理,然后使用mozebed读取这些内容</p>
<pre><code> fd = urllib2.urlopen(urllib2.Request(url, headers={'User-Agent': USER_AGENT}))
html = fd.read()
fd.close()
mozembed.open_stream(url, "text/html")
mozembed.append_data(html, len(html))
mozembed.close_stream()
</code></pre>