我想在另一個網站上找到一個字符串。我一直在看解析器,我不知道最好的解決方法。我看了一個HTML DOM解析器,但我只需要一個簡單的一行輸出。我只想獲得鏈接「url:'http://s2.example.com/streams/i23374.mp4?k=12f34588cf171f3bbf3d35da4db43b06'」到一個變量。PHP解析器 - 在HTML中查找字符串
<script>
flowplayer("player", "http://www.example.com/flowplayer-3.2.16.swf", {
canvas: {
backgroundGradient: "none",
backgroundColor: "#000000"
},
clip: {
provider: 'lighttpd',
url: 'http://s1.example.com/streams/i23374.mp4?k=12f34588cf171f3bbf3d35da4db43b06',
scaling: 'fit'
},
plugins: {
lighttpd: {
url: 'http://www.example.com/flowplayer.pseudostreaming-3.2.12.swf'
}
}
});
</script>
查看phpQuery或QueryPath的單行程。這種DOM遍歷前端(或簡單的longwinded DOMDocument)仍然只會爲您提供Javascript blob。你需要一個正則表達式和/或JSON/L解析器來提取URL。 – mario