开发者

New preg-repleace for youtube

Welcome,

I notice that Youtube make some changes into their website code.

Anyone have idea how make it working today ?

That's my script (don't work anymore)

preg_match('/"video_id": "(.*?)"/', $page, $match);
$var_id = $match[1];

preg_match('/"t": "(.*?)"/', $page, $match);
$var_t = $match[1];

Look at source of example Youtube video page:

http://www.youtube.com/watch?v=w_J27GxPNM0 (yes i like that song very much)

Now the t variable can be found under

<script>
  (function() {
   var isIE = /*@cc_on!@*/false;

I don开发者_运维知识库t paste full because it's very long.

Regards


Just looking at it, it seems that this should work easily enough:

pregmatch('/&video_id=([a-zA-Z0-9-%_]*)&/', $page, $match);
$var_id = $match[1];

pregmatch('/&t=([a-zA-Z0-9-%_]*)&/', $page, $match);
$var_t = $match[1];

By the way, if you want to be able to do this yourself, it's quite easy. You just need to learn how to use something called a regex. This website is particularly helpful: http://regular-expressions.info/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜