This commit is contained in:
wangjinlei
2025-03-20 14:13:53 +08:00
parent eefa89d00d
commit a05fa9b8de
2 changed files with 45 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ use think\Db;
use think\Queue;
use think\Env;
use think\Validate;
use GuzzleHttp\Client;
/**
* Description of Auto
@@ -31,6 +32,40 @@ class Auto extends Base
}
public function ZQTest(){
$data = $this->request->post();
$rule = new Validate([
"url"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$client = new Client();
$response = $client->request('GET', $data['url']);
$res = self::extractWeChatArticle($response);
return jsonSuccess($res);
// 获取响应内容
}
private function extractWeChatArticle($htmlContent) {
$dom = new DOMDocument();
@$dom->loadHTML($htmlContent); // 加载HTML内容@是为了抑制加载HTML时的警告
// 通过XPath获取文章内容
$xpath = new DOMXPath($dom);
$nodes = $xpath->query('//div[@class="rich_media_content"]'); // 这个XPath会获取微信文章的主要内容
if ($nodes->length > 0) {
return $nodes->item(0)->nodeValue;
}
return null;
}
/**
* 推送邮件给审稿人提醒审稿人
*/