我需要从 html 网页中提取一个值(id 值)。该值
包含在 JavaScript 代码中。
<script type="text/JavaScript">
var geoInstance = gioFinder("geo");
geoInstance.setup({
id: "126568949", // i need this
geometre: "triangle",
type: "html",
image: 'https://example/126568949.jpg',
});
</script>
我的代码 php 是
<?php
$filename = "https://examlpe.com";
$handle = fopen($filename, "r");
if ($handle) {
while (!feof($handle)) {
$text. = fread($handle, 128);
}
fclose($handle);
}
// How can you do
//right answer is .
$result = preg_match('/(?<=id: ")(.*)(?=",)/', $text, $matches);
echo $matches[0];
//end
?>