Skip to content

Commit

Permalink
Travis Build 5
Browse files Browse the repository at this point in the history
  • Loading branch information
Rits1272 committed May 9, 2019
1 parent 915b6e6 commit a0dd52f
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions pyquotes/pyquotes_test.py
Expand Up @@ -53,18 +53,17 @@ def get_quotes(person, category):
count += 1

# Getting the quote of the related author

get_quote = soup_author.find_all('a', attrs={'title':'view quote'})

get_quote = soup_author.find_all('a', attrs={'title': 'view quote'})
quote_list = []
big_list = []
for i in range(count):
quote_list.append(get_quote[i].text)
big_list.append(quote_list)

if len(quote_list) == 0:
if len(quote_list)==0:
return("Oops! It seems that there are no quotes of the author of that category.\nYou may consider changing the category or the author ")
quote_list.append(person)

return(quote_list)


Expand All @@ -77,10 +76,9 @@ def get_quote(person, category):
:param category: Category of quote e.g. Motivational
:param return: A tuple (quote, author_of_the_quote)
"""

quotes = get_quotes(person, category)
length = len(quotes)
if(length == 0): # In case no quote of the author exist for that category.
if(length==0): # In case no quote of the author exist for that category.
return("No quotes found of that category")
else:
random_number = random.randint(0, length-1)
Expand All @@ -90,39 +88,38 @@ def get_quote(person, category):

return(tuple(list))


def get_quote_of_the_day():
"""
This fuction returns quote of the day.
:param return: A tuple (quote, author_of_the_quote)
"""

URL = "https://www.brainyquote.com/quote_of_the_day"
list = []

# Sending a HTTP request to the specified URL and saving the response from server in a response object called response.
response = requests.get(URL)

soup = BeautifulSoup(response.content, 'html5lib')
a_tags = soup.findAll('img', alt=True)
# Getting all the a tags of the page.

# Getting all the a tags of the page.
quote_of_the_day_atag = str(a_tags[0])

# Grabbing the first a tag of the page
matches=re.findall(r'\"(.+?)\"', quote_of_the_day_atag)

matches=re.findall(r'\"(.+?)\"', quote_of_the_day_atag)
# A regular expression which gives a list of all text that is in between quotes.

quote_author_split_list = str(matches[0]).split('-')
# Get a list of quote_of_the_day and the author

# Get a list of quote_of_the_day and the author
quote_of_the_day = matches[0].replace(quote_author_split_list[-1], '')
quote_of_the_day = quote_of_the_day.replace('-', '')
author_name = quote_author_split_list[-1]
# Gives the author_name

# Gives the author_name
author_name = author_name.replace(' ', '')

# Removes any extra space
list = (quote_of_the_day, author_name)

Expand Down

0 comments on commit a0dd52f

Please sign in to comment.