我在第p = wikipedia.page(line)
行收到错误。
- requests.exceptions.ConnectionError :('Connection aborted。',BadStatusLine(“''”,))
我的INTERNET连接工作正常
我没弄错我的代码。
请帮忙 !谢谢
import wikipedia
import sys
import os
file_dir = sys.argv[1]
for file_name in os.listdir(file_dir):
with open(os.path.join(file_dir, file_name)) as fd:
while True:
line = fd.readline()
if len(line) == 0:
break
line = line.strip()
if len(line) == 0:
continue
p = wikipedia.page(line)
f = open("/home/data/"+file_name,"a")
print line
f.write(line)
f.write("***")
try:
data = p.content
data = data.encode("utf8")
f.write(data)
print " DONE"
f.write("\n")
except:
print " NOT done"
continue