Fetch youtube links from HTML code
For fetching youtube links from HTML code , I have written a simple code with Python that can retrieve all links from HTML codes.
#!/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
In my regex I have 2 types of tags , iframe or param. So if you have another one you can add that in the parenthesis like (mytag|iframe|param) and so on.
Be success.
Written by Morteza Nourelahi Alamdari
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#