Created
March 1, 2012 03:20
-
-
Save greglinch/1946992 to your computer and use it in GitHub Desktop.
Example of how to extract a link in Python using only the find() function
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
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] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment