12345678910111213141516171819202122232425 |
- import requests
- from django.conf import settings
- from .scrapper import scrape_reviews
- from .utils import get_max_date, store_into_database
- from .models import YelpLocation
- BROWSER_URI = getattr(settings, 'BROWSER_URI')
- def store_yelp_reviews(location, n_pages):
- location_url = location.url
- max_date = get_max_date(location)
- reviews = scrape_reviews(
- location_url=location_url,
- max_date=max_date,
- n_pages=n_pages
- )
- if reviews:
- store_into_database(reviews, location)
- def populate_reviews():
- locations = YelpLocation.objects.all()
- for yl in locations:
- store_yelp_reviews(yl, 1)
|