一个php采集类,含上载远程图片并替换原文

WBOY
Release: 2016-06-13 11:03:34
Original
869 people have browsed it

一个php采集类,含下载远程图片并替换原文

今天没事完善了一个php采集类,这给大家分享下。

本实例,可以,自动下载远程图片,并替换文章中的图片地址。。。

实例下载地址   http://download.csdn.net/detail/open520yin/4899183

实例:

<?phpheader ("Content-Type: Text/Html"); $url = "http://sh.sina.com.cn/travel/message/2012-12-16/191225659_5.html";  include("Snoopy.class.php");  $snoopy = new Snoopy;  $snoopy->fetch($url); //获取所有内容  $html = $snoopy->results; //显示结果  $title = $snoopy->getTitle();//获取标题  $text = $snoopy->getCent('<div class='\"(.*)\"' id='\"artibody\"'>','<p class='\"page\"'>');//获取主体//替换规则$arr = array(	0=>'<span id='\"_function_code_page\"'>(.*?)</span>',	1=>'<a href="%5C%22(.*)html#page_pic%5C%22">',	2=>'</a>',	3=>'</p>
<div class='\"article-video' artice-pic vid='\"\"'></div>',	4=>'</div>',	5=>'<a name="%5C%22page_pic%5C%22">',	6=>'<!--(.*)-->',	7=>'<span class='\"img_descr\"'>(.*?)</span>',); $text = $snoopy->replace($text,$arr);//过滤echo $snoopy->saveImg($text);  //下载远程图片,并替换文章图片地址?></a>
Copy after login

有需要的朋友,可以自己下载再完善。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template