Skip to content

Instantly share code, notes, and snippets.

@greglinch
Created March 1, 2012 03:20
Show Gist options
  • Save greglinch/1946992 to your computer and use it in GitHub Desktop.
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
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