tags:

views:

37

answers:

3

I would like to know whether it a possible to detect whether a HTML page contains a video.

I know that one possible way is to look for ".swf" in the HTML source code. But most of the pages do not contain the file name.

For example, given following URL and possibly its source code, is it possible to find out whether it contains a video: http://www.cnn.com/video/

+3  A: 

There are many ways to embed Video into a HTML page - as Flash Video or instances of Platform-Specific players through <object> and <embed> tags (but not every one of those tags is a video! The same holds true for .swf - it's just the file extension of Flash files, Video or not), the new HTML 5 <video> tag... They are not impossible to find out but it's a lot of work to catch all possible player types, formats and embed codes, and will result in a lot of false positives / negatives.

Then, there are JavaScript libraries that initialize players after the containing page has loaded - those are almost impossible to detect.

It's still a very complex issue to get video into a web page reliably, and subsequently, it's even more complex to find it out. Depending on what you are trying to achieve, I would consider dropping it.

Pekka
+1 the answer pretty much sums it up... :)
Gaby
Hi Pekka, Thanks for the detailed answer.
userlite
A: 

Check if an <object> tag exists in the DOM and check its content type and parameters. You will find the pattern by yourself.

SHiNKiROU
A: 

You can also search for .flv, or .mp4 in the source code.

Doo Dee
It's extremely unreliable. A Flash movie could contain the reference to the flv file in the movie itself.
Pekka