OxbridgeEconomics commited on
Commit
c9d52fa
·
unverified ·
1 Parent(s): b68d569

Update utils.py

Browse files
Files changed (1) hide show
  1. controllers/utils.py +6 -3
controllers/utils.py CHANGED
@@ -675,9 +675,12 @@ def crawl_by_url(url, article):
675
  contenteng = ''
676
  for element in contentcn.split("\n"):
677
  contenteng += translate(element) + '\n'
678
- if detect(contenteng) != 'en':
679
- for element in contentcn.split("。"):
680
- contenteng += translate(element) + '. '
 
 
 
681
  article['content'] = repr(contenteng)[1:-1].strip()
682
  try:
683
  article['subtitle'] = summarize(article['content'])
 
675
  contenteng = ''
676
  for element in contentcn.split("\n"):
677
  contenteng += translate(element) + '\n'
678
+ try:
679
+ if detect(contenteng) != 'en':
680
+ for element in contentcn.split("。"):
681
+ contenteng += translate(element) + '. '
682
+ except Exception as e:
683
+ print(f"An unexpected error occurred: {e}")
684
  article['content'] = repr(contenteng)[1:-1].strip()
685
  try:
686
  article['subtitle'] = summarize(article['content'])