1
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 推送邮件给审稿人提醒审稿人
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user