Explorar o código

fix a small bug in yelp scrapping

Mohidul Islam %!s(int64=4) %!d(string=hai) anos
pai
achega
5dfd4f6c77
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  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))