下载后无法打开文件的问题
我有一个用于在reddit上进行一些刮擦的脚本。
import praw
import requests
def reddit_scrape():
count = 0
for submission in subreddit.new(limit = 100):
if (is_known_id(submission_id = submission.id)):
print('known')
continue
save_id(submission.id)
save_to_dict(id = submission.id, txt = submission.title)
img_data = requests.get(submission.url).content
with open(submission.id, 'wb') as handler:
handler.write(img_data)
print(submission.url)
count += 1
if count >= 3: break
但是,当我尝试打开保存为处理程序的文件时,它没有扩展名,我无法打开它。
我不知道是什么原因导致了这个问题,因为它在不久前工作了。
请随时让我知道我是否缺少任何信息,因为这只是整个脚本的一部分。
I have a script which is used to do some scraping on Reddit.
import praw
import requests
def reddit_scrape():
count = 0
for submission in subreddit.new(limit = 100):
if (is_known_id(submission_id = submission.id)):
print('known')
continue
save_id(submission.id)
save_to_dict(id = submission.id, txt = submission.title)
img_data = requests.get(submission.url).content
with open(submission.id, 'wb') as handler:
handler.write(img_data)
print(submission.url)
count += 1
if count >= 3: break
However, when I try to open the file saved as handler, it does not have an extension and I am not able to open it.
I have no idea what is causing this issue, as it was working perfectly a while ago.
Feel free to let me know if I am missing any info, as this is just part of the entire script.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论