<?php
/*
PHP正则提取公众号文章页身份相关信息
var svrDate = '1703426514'; //某时
var oriCreateTime = '1703417280'; //某时
var createTime = '2023-12-24 19:28'; //文章时间
var selfUserName = "gh_12966fe****9"; //原始ID
<span class="profile_meta_value">wy****200</span> //号
window.source_appid = 'wx4a1d12efd****3fc'; //appid
*/
$k = "title|selfUserName|createTime|svrDate|oriCreateTime";
$content = file_get_contents('app.txt'); //app.txt本地保存代码供测试,可改为公众号文章网址
$pattern = "/var\s+($k)\s+\=\s*['\"](.+?)['\"];/"; //var aaa=...
preg_match_all($pattern, $content, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$yuan = $match[1]; $vvvv = $match[2];
echo "<p>$yuan => $vvvv</p>";
}
$pattern2 = '/<span class="profile_meta_value">(\w+)<\/span>/'; //profile_meta_value
preg_match_all($pattern2, $content, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$yuan = $match[1]; echo "<p>profile_meta_value => $yuan</p>";
}
$pattern3 = '/source_appid\s+\=\s*[\'"](\w+)[\'"];/'; //source_appid
preg_match_all($pattern3, $content, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$yuan = $match[1]; echo "<p>source_appid => $yuan</p>";
}
?>
意图,在本站只让留 留有本站链接的公众号文章,并记录该文章的原始ID|APPID|账号
今后用到发文备查,也供分享