这是代码片段:
for i in obj:
url = "someurl" + i
oars = requests.get(url, timeout=1)
soup = BeautifulSoup(oars.content)
fout = open(i + ".html", "wt")
print((type(soup.prettify)))
fout.write(oars.text)
oars.close
#fout.write(soup.get_text())
# Still not working, using zsh for now
if call("html2text " + i + ".html" + ">" + i + ".txt", shell=True) == 0:
print("yay")
#call("rm -f " + i + ".html", shell=True)
else:
print(i)
但是 html2text 只是创建空的 txt 文件,而不是正确地管道输出。我什至尝试替换html2text
为elinks -dump
但无济于事。