import requests
from bs4 import BeautifulSoup


def scrape(start, end, logging=True):
    """
    Scrape all the reviews from dealerrater.com for the McKaig 
    Chevrolet Buick dealership.

    Parameters:
        start: the page of reviews to start scraping
        end: the last page of reviews to scrape
    
    Returns:
        texts: a list of strings that are the reviews from the website
    """
    PAGE_START = start
    PAGE_END = end
    texts = []

    # Scrape the data from pages 1-5
    for page in range(PAGE_START, PAGE_END + 1):
        if logging:
            print("Scraping page"+str(page)+"...")
        url = "https://www.dealerrater.com/dealer/McKaig-Chevrolet-Buick-A-Dealer-For-The-People-dealer-reviews-23685/page"+str(page)+"/?filter=ALL_REVIEWS#link"
        res = requests.get(url)
        soup = BeautifulSoup(res.content, "html.parser")

        # Get the reviews on this page
        for p in soup.select("p.review-content"):
            texts.append(p.get_text())
    return texts