We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
try: res = auth_get(url, session, username, password, timeout=15) except requests.exceptions.Timeout: print('请求超时:', filename) return print('开始下载:' + filename)
auth_get里面调用get的时候是没有stream=True的 另外,下载用异步应该就行了,没必要多进程吧
The text was updated successfully, but these errors were encountered:
你好,首先这个“没有stream=True”是指有什么问题呢? 第二个问题的话,确实用协程更合适一点,毕竟爬虫是IO密集型任务。刚开始写的时候是我疏忽了,后来觉得效率还能接受就没有改了,之后会考虑换成协程的。 最后非常感谢你的建议,有其它问题或者建议的话也欢迎提出。
Sorry, something went wrong.
requests的get有个参数stream,默认是False,这样就会在get的时候阻塞直到整个response下载完毕,所以代码中print开始下载的时候,已经下载到内存中了。
明白了,这里的显示确实有问题,下一个版本(如果有的话)我打算把 print 开始下载移到 try 上面,这个解决方案可能更合适一点。用 stream 下小图片的话感觉还是没必要了,而且假设是要分块写入文件的话,网络断开还会导致图片文件不完整。
No branches or pull requests
auth_get里面调用get的时候是没有stream=True的
另外,下载用异步应该就行了,没必要多进程吧
The text was updated successfully, but these errors were encountered: