【发布时间】:2020-01-30 19:59:15
【问题描述】:
我需要从 html 网页中提取一个值(id 值)。 此值包含在 JavaScript 代码中。
我的爬虫 php >
<?php
if (isset($_POST['submit']))
{
$handle = fopen($_POST['website_url'], "r");
if ($handle)
{
while (!feof($handle))
{
$text .= fread($handle, 128);
}
fclose($handle);
}
$result = preg_match('(?<=id: ")(.*)(?=",)', $text);
echo $result;
}
?>
我的 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>
我需要提取 id 值但 preg_match 不起作用
【问题讨论】:
-
请注意 java != javascript
标签: javascript php preg-match scrape