如何用正则表达式和图片获取到一个页面中指定的页面的内容

如图所示, 想要获取到一个页面的中括号中的部分 如何写正则表达式,如何写php程序?
比如页面的url是 xzhuji.com 怎么提取其中的这部分内容
最新回答
哥的名称亮瞎你的狗眼

2024-05-04 01:52:11

<?php

$url = "xxx";

$content = file_get_contents($url);

$pattern = '#<code[^>]*?id="searchWord"[^>]*?>\s*(\[&quot;.*?\])</code>#is';
if(preg_match($pattern, $content, $match)) {
    echo $match[1];
} else {
    //匹配不到数据(可能是正则没写对)
}