【发布时间】:2018-09-17 11:00:30
【问题描述】:
我有这段代码可以用 curl 向我输出源 URL 的源页面!
$url = 'http://source-page.com';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // add this one, it seems to spawn redirect 301 header
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); // spoof
$output = curl_exec($ch);
curl_close($ch);
$html = str_get_html($output);
在 $output 我有这个:
var flashvars = {
"image_url":"http://path-to-image.com",
"video_title":"This is video title",
"videoUrl":"http://this-is-path-to-mp4.com"
}
我想回显 videoUrl,我已经尝试过:
$videoUrl = $html->find('flashvars[0].videoUrl');
echo $videoUrl
并且给了我空的结果。有什么好的代码可以做到这一点?
【问题讨论】:
标签: javascript php html curl simple-html-dom