فهرست منبع

fix a small bug in yelp scrapping

Mohidul Islam 4 سال پیش
والد
کامیت
5dfd4f6c77
1فایلهای تغییر یافته به همراه3 افزوده شده و 2 حذف شده
  1. 3 2
      yelp/utils.py

+ 3 - 2
yelp/utils.py

@@ -48,7 +48,8 @@ def store_into_database(reviews, location):
 def populate_yelp_reviews():
     yelp_locations = YelpLocation.objects.all()
     for yl in yelp_locations:
-        reviews = scrape_reviews(location_url=yl.url, n_pages=2)
-        store_into_database(reviews, yl)
+        reviews = scrape_reviews(location_url=yl.url, n_pages=1)
+        if reviews:
+            store_into_database(reviews, yl)
         # pause for 30-60 sec to make request more human-like.
         sleep(random.randint(30, 60))