php - 从 php 中的站点获取部分 youtube 链接
问题描述
我需要一个获取//www.youtube.com/embed/AMUHafKH0oY?wmode=opaque
IDAMUHafKH0oY
不断变化的 youtube 行,我需要它自动从该行中拉出...关闭此页面http://www.sequesteraccess.com/livefeed
但它一直从页面上的第一个 youtube 视频中抓取,因此有关如何完成此操作的任何建议? 任何建议都会非常感谢提前!
这是我迄今为止尝试过的
<?php
function getURL($u){
$ops = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept: text/html\r\n" .
"User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0\r\n"
)
);
$co = stream_context_create($ops);
$r = file_get_contents('http://' . $u, false, $co);
return $r != false ? $r : "";
}
function GetStringBetween($string, $start, $finish){
$string = " ".$string;
$position = strpos($string, $start);
if ($position == 0) return "";
$position += strlen($start);
$length = strpos($string, $finish, $position) - $position;
return substr($string, $position, $length);
}
$grab = file_get_contents('http://www.sequesteraccess.com/livefeed');
$stream = GetStringBetween($grab, 'YOU ARE NEW TO SEQUE..."},"hSize":null,"floatDir":null,"html":"<iframe src=\"//', '&');
?>
<?=$stream?>
解决方案
推荐阅读
- cypress - 柏树处理小数位
- mysql - 查询匹配()导致重复行和不同()不起作用
- php - password_verify() 即使输入正确的值也总是返回 False
- php - php-fpm 消耗内存并使服务器无法访问?
- javascript - 如何将类添加到javascript中的html字符串中的元素?
- r - 获取对象列表并将对象符号保留为名称
- javascript - 使用 jquery 在 .each 循环中添加事件监听器
- angular - 如何使用 Angular Http 拦截器来处理 Angular 中的请求超时
- node.js - 在集合中查找嵌套(嵌入)对象
- c# - 如何根据列值更改行按钮类