使用PHP提取视频网站页面中的FLASH地址的代码
这几天工作中需要写个程序对于一个视频网站地址,如优酷的某个地址,提取出其中的FLASH地址来。
然后我用PHP实现了这个功能,我觉得用PHP来做这项工作简直是一种享受!使用其提供的强大的HTML页面处理函数和正则表达式,短短的几行代码就能搞定这个功能。
贴一下关键代码:
代码如下:
//获取优酷页面中的flash地址
function get_flash_url( $url )
{
$lines = file($url);
foreach ($lines as $linenum=> $line) {
preg_match_all('||',$line,$result);
$swfurl=$result[1][0];
if(!empty($swfurl))
return $swfurl;
}
}
?>
$url=$_SERVER["QUERY_STRING"];
$flashurl= get_flash_url($url);
echo ( $flashurl );
?>
比如这个文件我们存为 test.php,那么我们只需要运行 test.php?优酷视频的url 就可以解析出FLASH地址了。
思路很简单,就是先看看优酷视频网页的HTML代码里关键FLASH地址那段的特征。随便找个网页,比如我们可以看到这一段:
flash地址:
然后使用正则表达式来将其中的地址段匹配掉,就OK了。
然后使用正则表达式来将其中的地址段匹配掉,就OK了。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Seashell Riddle Solution
2 weeks ago
By DDD
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
CakePHP Tutorial
1377
52

