我需要下载一个文件,但为了这样做,我必须接受许可协议。
例如,从
http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html
,
我要下载
Linux x86 146.84 MB jdk-8u40-linux-i586.rpm
我想到了类似的东西:
browser = spynner.Browser()
url = "http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html"
browser.load(url)
browser.runjs("acceptAgreement(window.self, 'sjre-8u40-oth-JPR');")
file = browser.download("http://download.oracle.com/otn/java/jdk/8u40-b26/jdk-8u40-linux-i586.rpm")
if file == None or file == "":
print("Wrong")
else:
data = file.read()
with open("code3.rpm", "wb") as code:
code.write(data)
但它总是说“错误”,所以file
变量中可能没有任何内容。
有人可以给我一个提示吗?