from bs4 import BeautifulSoup


def crawl_url(input_url):
    """
    Finds reddit post titles at a given url and returns a string
    containing them, separated as individual sentences.
    """
    intitles = ""
    soup = BeautifulSoup(input_url.text, 'lxml')

    # Find all the titles on a single reddit page
    titles = soup('a', {'class': 'title may-blank '})

    # Get each title & separate into sentences
    for title in titles:
        intitles += title.text + '. '
    if intitles == '':
        print("Crawl did not seem to work, please try a different subreddit!")
        exit()
    return intitles