我有这样的脚本
import mechanize
url = "http://www.globalhide.com/browse.php?u=u=http://www.whoisxmlapi.com/whoisserver/WhoisService?domainName=google.com"
br = mechanize.Browser()
br.set_handle_robots(False)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
response = br.open(url)
content = response.read()
f = open('q.html', 'w')
f.write(content)
f.close()
当我从 python shell 运行它时,我需要这样的结果,结果是正确的。但是当我将它保存在 something.py 文件中并像这样运行python something.py
q.html 的内容时
,我的代码有什么问题?