diff --git a/pyquotes/powerquotes/powerquotes_scraper.py b/pyquotes/powerquotes/powerquotes_scraper.py index 97eeb8b..bbc1233 100644 --- a/pyquotes/powerquotes/powerquotes_scraper.py +++ b/pyquotes/powerquotes/powerquotes_scraper.py @@ -45,7 +45,6 @@ def get_quotes(category): for h in range(int(len(quote_list)/2)): main_list.append((quote_list[h+t], quote_list[h+1+t])) t = t+1 - return main_list @@ -59,16 +58,10 @@ def get_quote(category): quotes = get_quotes(category) length = len(quotes) if(length == 1): - quote_with_author_list = [] - quote_with_author_list.append(quotes[0]) - return(tuple(quote_with_author_list)) + return(quotes[0]) else: random_number = random.randint(0, length - 1) - quote_with_author_list = [] - quote_with_author_list.append(quotes[random_number]) - quote_with_author_list.append(person) - - return(tuple(quote_with_author_list)) + return(quotes[random_number]) # quotes = get_quotes("power") diff --git a/pyquotes/scraper.py b/pyquotes/scraper.py index a0a031b..0ce9ef1 100644 --- a/pyquotes/scraper.py +++ b/pyquotes/scraper.py @@ -23,14 +23,16 @@ def get_quotes(person: (None, str) = None, category: (None, str) = None): if person is not None: # person's name is provided # formatting the name to fit as per URL Person = "-".join(person.strip().split()) - person_link = requests.get(parent_link + "/quotes/authors/" + Person).text + person_link = requests.get( + parent_link + "/quotes/authors/" + Person).text soup_obj = BeautifulSoup(person_link, "lxml") for interest in soup_obj.find_all("div", class_="card-body text-center"): quote = interest.p.find("a", class_="href-noshow").text tag = interest.p.find("a", class_="category-tag").text result.append((quote, person)) - if category is not None:: # category's name is provided + if category is not None: + # category's name is provided category_link = requests.get( parent_link + "/quotes/categories/" + category ).text