我有这个视频标签:
<video src="https://videosource.com" x-webkit-airplay="allow"></video>
我像这样使用PHP Simple HTML DOM Parser:
$html = str_get_html($output);
$output2 = $html->find('video', 0);
preg_match('/\src:"(.*?)\"/', $output2, $match);
但是回报我空虚的价值。我怎么能得到https://videosource.com?
使用正则表达式解析html并不是一个好主意,但是因为你有没有嵌套的视频标签所以你可以在这里使用它。
你需要更正你的正则表达式并使用它,
src="([^"]*?)"
演示,
https://regex101.com/r/HPGzRq/1
EDIT1
这是你可以使用的那种PHP代码,
$output2 = '<video src="https://videosource.com" x-webkit-airplay="allow"></video>';
preg_match('/src=\"([^\"]*?)\"/', $output2, $match);
print($match[1]);
$ match [1]捕获并返回正则表达式中的组1,这些行的输出是,
https://videosource.com