当用python selenium爬虫大批量下载文件时,当我们知道该文件的网址(如http://....a.txt)时
浏览器会自动打开without download,而我只想下载,翻了很久没找到解决方法(有的比较麻烦,用弹窗的方式解决),偶然看到了这篇,试了很久,原来可以这么简单。。。在这里打个卡。。。
dr= webdriver.Chrome()
dr.get('https://a/in.xml?_upd=true')#随便写的网址(https://a/in.xml)
#...
with open(os.path.join(download_dir,'a.xml'), "w") as file:
file.write(dr.page_source)
即可直接保存