发布日期:2022-12-16浏览次数:712 来源:福州网站建设
$url="https://mp.weixin.qq.com/s/DYB2ApEjsE8TYPsSOA4DEw";
$html_content= file_get_contents($url);
preg_match('/"js_content" style="visibility: hidden;"-->([\s\S]*?)<\/div/',$html_content,$m);
$content=$m[1];
//获取图片存到本地
preg_match_all('/data-src="([\s\S]*?)" data-ke-src="([\s\S]*?)"/',$content,$a);
foreach ($a[1] as $key => $value) {
$img_url=set_img($value);
$content = str_replace($value, $img_url, $content);
$content = str_replace("data-src", "src", $content);
}
echo $content;
/**
* [set_img description]
* @Author huangxiaojian(www.xl779.com)
* @DateTime 2022-12-16T19:25:31+0800
* @param [type] $url [description]
*/
function set_img($url){
$ext = ".png"; //获取图片格式
$img = file_get_contents($url);
$img_name="upload/cai/".getMillisecond().$ext;
file_put_contents("../".$img_name,$img);
return "/".$img_name;
}
function getMillisecond() {
list($s1, $s2) = explode(' ', microtime());
return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000);
}
以上是由福州网站建设的小编为你分享了"php采集微信公众号文章源代码 可用 2022 2023"文章,如果你在这方面有什么问题,随时联系我们