noodles 2 years ago
parent
commit
f59eeba891
1 changed files with 9 additions and 6 deletions
  1. 9 6
      run4.py

+ 9 - 6
run4.py

@@ -102,21 +102,21 @@ def parsing_js(resp):
         if txt[6][4][7]:
             output['rating'] = str(txt[6][4][7])
         else:
-            output['rating'] = ''
+            output['rating'] = None
 
         if txt[6][4][8]:
             output['user_ratings_total'] = str(txt[6][4][8])
         else:
-            output['user_ratings_total'] = ''
+            output['user_ratings_total'] = None
 
         if txt[6][4][2]:
             output['price_level'] = str(len(['$' for i in txt[6][4][2] if i == '$']))
         else:
-            output['price_level'] = ''
+            output['price_level'] = None
     else:
-        output['rating'] = ''
-        output['user_ratings_total'] = ''
-        output['price_level'] = ''
+        output['rating'] = None
+        output['user_ratings_total'] = None
+        output['price_level'] = None
 
     if txt[6][37][0]:
         output['lon'] = txt[6][37][0][0][8][0][1]
@@ -555,6 +555,9 @@ def main():
             error_table3 = db['error_list3']
             error_table3.insert({'name':name,'keyword':keyword,'item_url':item_url,'crawler_date':datetime.today().strftime("%Y/%m/%d %H:%M")})
             traceback.print_exc()
+            driver.quit()
+            print('drvier restart...')
+            driver = brower_start(port)
 
 if __name__ == '__main__':
     main()