我正在创建一个python脚本,它使用bash对文件中包含的日语单词列表执行wget操作。我只想用卷发,但这有编码问题。使用wget,它确实下载了html,但它将其转储到当前目录中,其中包含诗意标题,如:
試%E8%A1%8C%E9%8C%AF誤我希望它能把html放到诸如“output/混合..txt”这样听起来不错的地方。它确实创建了这些听起来不错的文件,但里面没有任何内容。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
with open("words") as f:
for line in f:
text = unicode(line, "utf-8")
os.system("wget \'https://kotobank.jp/word/" + line.strip() + "'> output/" + line.strip() + ".txt")
#print("wget \'https://kotobank.jp/word/" + line.strip() + "'>> output/out.txt")文件"words“如下:
追究
花器
陶磁器
枯渇
風合い
繊維
混合
アボード
受け継い
試行錯誤
硬質发布于 2017-11-13 07:22:50
使用-O file选项而不是重定向输出:
os.system("wget \'https://kotobank.jp/word/" + line.strip() + "' -O " + line.strip() + ".txt"有关更多信息,请参见wget 文档。
https://stackoverflow.com/questions/47258602
复制相似问题