PHP正则提取公众号文章页身份相关信息APPID/原始ID/微信号

wy****200 //号
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 "

$yuan => $vvvv

"; } $pattern2 = '/(\w+)<\/span>/'; //profile_meta_value preg_match_all($pattern2, $content, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $yuan = $match[1]; echo "

profile_meta_value => $yuan

"; } $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 "

source_appid => $yuan

"; } ?>

意图,在本站只让留 留有本站链接的公众号文章,并记录该文章的原始ID|APPID|账号

今后用到发文备查,也供分享

你可能感兴趣的:(php,微信公众平台)