-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathudacitygnt.py
More file actions
21 lines (19 loc) · 777 Bytes
/
udacitygnt.py
File metadata and controls
21 lines (19 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def get_next_target(page):
start_link = page.find('<a href=') # HINT: put something into the code here
if start_link == -1:
return None, 0
start_quote = page.find('"', start_link)
end_quote = page.find('"', start_quote + 1)
url = page[start_quote + 1:end_quote]
return url, end_quote
def print_all_links(page):
url = 1
while url != None:
url, endpos = get_next_target(page)
if url != None:
print url
page = page[endpos:]
#url, endpos = get_next_target(page)
#page = 'no llinks here'
page = 'contents <a href="somelinkhere"> text </a> of some web page as a string contents <a href="somelinkhere2"> text </a> of some web page as a stringcontents <a href="somelinkhere3"> text </a> of some web page as a string'
print_all_links(page)