add postprocessing error handling
This commit is contained in:
parent
6247a29f90
commit
c162c8ba44
1 changed files with 9 additions and 3 deletions
12
spiderss.py
12
spiderss.py
|
|
@ -129,10 +129,16 @@ def get_article_body(article, scrape):
|
|||
# Postprocess HTML
|
||||
def postprocess(text):
|
||||
|
||||
processor = subprocess.Popen(postprocessor.split(' '), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
||||
output = processor.communicate(input = text.encode())[0].decode().strip()
|
||||
try:
|
||||
processor = subprocess.Popen(postprocessor.split(' '), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
|
||||
(output, err) = processor.communicate(input = text.encode())
|
||||
if err:
|
||||
raise Exception(err.decode().strip())
|
||||
except Exception as e:
|
||||
error(' while postprocessing: {}'.format(e))
|
||||
sys.exit(1)
|
||||
|
||||
return output
|
||||
return output.decode().strip()
|
||||
|
||||
|
||||
# Get constructed article
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue