我正在尝试从给定代码中提取url标记:
(function(e,a){
var t={
"cdn_url":"https://f.vimeocdn.com",
"view":1,
"request":{
"files":{
"h264":{
"hd":{
"profile":113,
"origin":"level3",
"url":"https://09-lvl3-pdl.vimeocdn.com/01/3164/4/115821665/722085083.mp4?expires=1446817250&token=0cc7a9f36655f3a0afff3",
"cdn":"level3",
"height":720,
"width":1280,
"id":722085083,
"bitrate":2583,
"availability":114
},
"sd":{
"profile":112,
"origin":"level3",
"url":"https://09-lvl3-pdl.vimeocdn.com/01/3164/4/115821665/722083593.mp4?expires=1446817250&token=024b83dea6d2f4e4f57e1",
"cdn":"level3",
"height":360,
"width":640,
"id":722083593,
"bitrate":667,
"availability":114
}
},
"hls":{
"origin":"level3",
"all":"https://09-lvl3-hls.vimeocdn.com/1446820550-c34bde21acdff66dc5a0a7a4a701ba220774c80e/01/3164/4/115821665/master.m3u8",
"cdn":"level3"
},
"codecs":["h264"]
},
"ga_account":"UA-76641-35",
"expires":3600,
"timestamp":1446813350,
"signature":"6e5fbd174b7b4503945ffa8ae800f4b5",
"currency":"USD",
"session":"60ee52a4f9a681617d768b7bf329c10867b53cfe1446813350",
"cookie": {
"scaling":1,
"volume":1.0,
"quality":null,
"hd":null,
"captions":null},
我正在尝试从上面的代码中提取SD视频网址:
https://09-lvl3-pdl.vimeocdn.com/01/3164/4/115821665/722083593.mp4?expires=1446817250&token=024b83dea6d2f4e4f57e1
我正在使用PHP,因为它可以提供任何帮助! 我正在尝试下载视频,但为此我首先需要SD视频的网址。
提前致谢! :)
答案 0 :(得分:0)
这是抓住它的正则表达式:
@PersistenceContext
网址最终位于第一个(也是唯一一个)捕获组中。
但这是一种<非常粗暴的方式获得它。我建议你获取JSON对象并使用Persistence.createEntityManagerFactory('unit').createEntityManager()
来获得你想要的值。 (您的示例HTML不完整,所以我无法告诉您,获取JSON对象的正则表达式会是什么样的。)
此致
答案 1 :(得分:0)
如果这就是您所需要的,请尝试
"url":"([^"]*)"
https://regex101.com/r/tZ1iV5/2
代码中的使用示例:
$re = "/\"url\":\"([^\"]*)\"/";
$str = "(function(e,a){var t={\"cdn_url\":\"https://f.vimeocdn.com\",\"view\":1,\"request\":{\"files\":{\"h264\":{\"hd\":{\"profile\":113,\"origin\":\"level3\",\"url\":\"https://09-lvl3-pdl.vimeocdn.com/01/3164/4/115821665/722085083.mp4?expires=1446817250&token=0cc7a9f36655f3a0afff3\",\"cdn\":\"level3\",\"height\":720,\"width\":1280,\"id\":722085083,\"bitrate\":2583,\"availability\":114},\"sd\":{\"profile\":112,\"origin\":\"level3\",\"url\":\"https://09-lvl3-pdl.vimeocdn.com/01/3164/4/115821665/722083593.mp4?expires=1446817250&token=024b83dea6d2f4e4f57e1\",\"cdn\":\"level3\",\"height\":360,\"width\":640,\"id\":722083593,\"bitrate\":667,\"availability\":114}},\"hls\":{\"origin\":\"level3\",\"all\":\"https://09-lvl3-hls.vimeocdn.com/1446820550-c34bde21acdff66dc5a0a7a4a701ba220774c80e/01/3164/4/115821665/master.m3u8\",\"cdn\":\"level3\"},\"codecs\":[\"h264\"]},\"ga_account\":\"UA-76641-35\",\"expires\":3600,\"timestamp\":1446813350,\"signature\":\"6e5fbd174b7b4503945ffa8ae800f4b5\",\"currency\":\"USD\",\"session\":\"60ee52a4f9a681617d768b7bf329c10867b53cfe1446813350\",\"cookie\":{\"scaling\":1,\"volume\":1.0,\"quality\":null,\"hd\":null,\"captions\":null},";
preg_match($re, $str, $matches);
$matches[1]
包含您需要的值