OxbridgeEconomics commited on
Commit
b348cfd
·
unverified ·
1 Parent(s): 683897d

Update gov.py

Browse files
Files changed (1) hide show
  1. gov.py +4 -1
gov.py CHANGED
@@ -142,6 +142,7 @@ while i > -1:
142
  else:
143
  urls = subpage.xpath("//a[contains(@target, '_blank')]/@href")
144
  for url in urls:
 
145
  article = {}
146
  url = url.replace('../', 'https://www.gov.cn/zhengce/')
147
  if "https://www.gov.cn" in url:
@@ -185,6 +186,8 @@ while i > -1:
185
  article['sentimentScore'] = sentiment_score
186
  article['sentimentLabel'] = label_dict[sentiment_label]
187
  upsert_content(article)
 
 
188
 
189
  i = 0
190
  while i > -1:
@@ -251,4 +254,4 @@ while i > -1:
251
  article['sentimentLabel'] = label_dict[sentiment_label]
252
  upsert_content(article)
253
  except Exception as error:
254
- print(error)
 
142
  else:
143
  urls = subpage.xpath("//a[contains(@target, '_blank')]/@href")
144
  for url in urls:
145
+ try:
146
  article = {}
147
  url = url.replace('../', 'https://www.gov.cn/zhengce/')
148
  if "https://www.gov.cn" in url:
 
186
  article['sentimentScore'] = sentiment_score
187
  article['sentimentLabel'] = label_dict[sentiment_label]
188
  upsert_content(article)
189
+ except Exception as error:
190
+ print(error)
191
 
192
  i = 0
193
  while i > -1:
 
254
  article['sentimentLabel'] = label_dict[sentiment_label]
255
  upsert_content(article)
256
  except Exception as error:
257
+ print(error)