Skip to content

Commit

Permalink
修复 var msg_title 匹配规则
Browse files Browse the repository at this point in the history
  • Loading branch information
TransparentLC committed May 25, 2020
1 parent 55d3621 commit 5374a34
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions get_article_info.php
Expand Up @@ -5,7 +5,7 @@
//允许跨域
header('Access-Control-Allow-Origin: *');

if (empty($_GET['url'])) {
if (empty($_GET['url']) || strpos($_GET['url'], 'mp.weixin.qq.com') === false) {
$result['title'] = '';
$result['cover'] = '';
} else {
Expand All @@ -20,10 +20,10 @@
]);
$response = curl_exec($ch);

preg_match('/var msg_title = "[\S\s]*?";/', $response, $matches);
$result['title'] = empty($matches[0]) ? '' : str_replace(array('var msg_title = "', '";'), '', $matches[0]);
preg_match('/var msg_title = \'[\S\s]*?\'.html\\(false\\);/', $response, $matches);
$result['title'] = empty($matches[0]) ? '' : htmlspecialchars_decode(str_replace(['var msg_title = \'', '\'.html(false);'], '', $matches[0]));
preg_match('/var msg_cdn_url = "[\S\s]*?";/', $response, $matches);
$result['cover'] = empty($matches[0]) ? '' : str_replace(array('var msg_cdn_url = "', '";'), '', $matches[0]);
$result['cover'] = empty($matches[0]) ? '' : str_replace(['var msg_cdn_url = "', '";'], '', $matches[0]);
curl_close($ch);
};

Expand All @@ -38,7 +38,7 @@
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko',
]);
$filename = md5(mt_rand()) . '.jpg';
$filename = bin2hex(random_bytes(16)) . '.jpg';
file_put_contents($filename, curl_exec($ch));
curl_close($ch);

Expand Down

0 comments on commit 5374a34

Please sign in to comment.