"""File: url_list.py Purpose: Build a list of the links on a web page. Run: python url_list.py Input: root URL HTML filename Output: List of links on the page. Note: Each line of the HTML file is either a tag or a word. """ import requests #---------------------------------------------------------------------- def get_urls(pg_txt, root_url): """Extract urls from an html page stored as a string in pg_txt""" ulist = [] pg_strs = pg_txt.split('\n') for i in range(len(pg_strs)): pg_strs[i] = pg_strs[i].strip() if len(pg_strs[i]) >= 1: if pg_strs[i][0:2] == "