def bfsSearchMovie(url): href_queue = [] head = 0 movie_href = parseSearchPage(url) for movie_link in movie_href: movie_link = HOST_URL + movie_link href_queue.append({'href': movie_link, 'dist': 0}) while (head <= len(href_queue)): cur = href_queue[head] info = getMovieInfo(cur['href'], cur['dist']) head += 1 if info == None: continue for cast_href in info['cast_href']: movies = parseCastPage(cast_href) if movies == None: continue for movie in movies['movie_href']: href_queue.append({'href': movie, 'dist': cur['dist'] + 1}) print href_queue
def dfsSearchMovie(url, dist): # First parse the search page movie_href = parseSearchPage(url) for movie_link in movie_href: movie_link = HOST_URL + movie_link info = getMovieInfo(movie_link, dist) if info == None: continue dfsSearchCast(info, dist)