def main(): name = string_functions.get_input_name().lower() wiki_url = string_functions.name_to_url(name) try: html_soup = soup_operations_functions.get_html_soup(wiki_url) except HTTPError: error_message = ('No BeautifulSoup object likely due to invalid person and/or URL: {url}' .format(url=wiki_url)) raise Exception(error_message) soup_operations_functions.print_roles(html_soup) related_actors = actor_relationships.get_related_actors(html_soup) actor_relationships.print_related_actors(related_actors)
def main(): name = string_functions.get_input_name().lower() wiki_url = string_functions.name_to_url(name) try: html_soup = soup_operations_functions.get_html_soup(wiki_url) except HTTPError: error_message = ( 'No BeautifulSoup object likely due to invalid person and/or URL: {url}' .format(url=wiki_url)) raise Exception(error_message) soup_operations_functions.print_roles(html_soup) related_actors = actor_relationships.get_related_actors(html_soup) actor_relationships.print_related_actors(related_actors)
def get_related_actors(soup): related_actors = {} links = soup.find_all('a') for link in links: if link_after_all_actors(link, soup): break if not link_has_good_href(link): continue actor_slug = get_actor_slug(link) actor_url = string_functions.to_wiki_url(actor_slug) if actor_url in related_actors.values(): continue try: actor_soup = soup_operations_functions.get_html_soup(actor_url) except HTTPError: continue if soup_info_functions.is_an_actor(actor_soup): actor_name = soup_info_functions.get_person(actor_soup) if actor_name == soup_info_functions.get_person(soup): continue related_actors[actor_name] = actor_url print(actor_name) return related_actors