Created
September 5, 2012 14:11
-
-
Save mozillazg/3637230 to your computer and use it in GitHub Desktop.
cs101-unit1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write Python code that assigns to the | |
# variable url a string that is the value | |
# of the first URL that appears in a link | |
# tag in the string page. | |
# page = contents of a web page | |
page =('<div id="top_bin"><div id="top_content" class="width960">' | |
'<div class="udacity float-left"><a href="http://www.xkcd.com">') | |
start_link = page.find('<a href=') | |
start_quote = page.find('"', start_link) | |
end_quote = page.find('"', start_quote + 1) | |
url = page[start_quote+1:end_quote] | |
print url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment