Skip to content

Instantly share code, notes, and snippets.

@mortymacs
Created June 4, 2013 17:12
Show Gist options
  • Save mortymacs/5707738 to your computer and use it in GitHub Desktop.
Save mortymacs/5707738 to your computer and use it in GitHub Desktop.
Fetch youtube href(src) from html source code
#!/usr/bin/env python
import re
pattern = '.*<(iframe|param).*(src|value)="(?P<link>http://www.youtube.com/(embed|v)/[a-zA-Z0-9/\.\?&;=\+_-]+);?.*".*>.*</(iframe|param)>.*'
action = re.compile(pattern)
result = action.findall('<div><iframe.....></iframe><param......></param></div>')
print result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment