采集(file_get_contents)
来源:互联网 发布:电脑自动开关机软件 编辑:程序博客网 时间:2024/05/16 12:04
用file_get_contents进行采集
<?phpheader("content-type:text/html;charset=utf-8");$url="http://www.php7.com/dwzchd/aa.html";$file=file_get_contents($url);$pre='#<div class="mod-content clearfix show-content-bg">(.*)<div class="map-content clearfix">#isU';preg_match($pre,$file,$content);$pre1='#<a href="(.*)" .*">([^<>]*)</a>#isU';preg_match_all($pre1,$content[0],$content1);//print_r($content1);die;$count=count($content1[0]);//echo $count;die;$pre2='#<img src="(.*)" width="16" height="16" class="img1">#isU';preg_match_all($pre2,$content[0],$content2);foreach($content2[1] as $key => $val){ $content2[1][$key]= "http://www.php7.com/dwzchd/".$val; //echo $path['basename'];die; $img=file_get_contents($content2[1][$key]); file_put_contents("public/".$key.".png",$img);}//print_r($content2[1]);die;echo "加载图片成功";
下载图片
$count1=count($content2[1]);for($i=0;$i<$count1;$i++){//$arr1[]['picture']=$content2[1][$i];$img=file_get_contents($content2[1][$i]);file_put_contents("public/".rand(1000,9999).'.png',$img);}
Snoopy是什么? Snoopy是一个php类,用来模仿web浏览器的功能,它能完成获取网页内容和发送表单的任务。Snoopy的一些特点:1抓取网页的内容 fetch2 抓取网页的文本内容 (去除HTML标签) fetchtext3抓取网页的链接,表单 fetchlinks fetchform4 支持代理主机5支持基本的用户名/密码验证6 支持设置 user_agent, referer(来路), cookies 和 header content(头文件)7支持浏览器重定向,并能控制重定向深度8能把网页中的链接扩展成高质量的url(默认)9提交数据并且获取返回值10 支持跟踪HTML框架11支持重定向的时候传递cookies
snoopy,
include "Snoopy.class.php"; $snoopy = new Snoopy; $snoopy->fetchtext("http://www.php.net/"); print $snoopy->results; $snoopy->fetchlinks("http://www.phpbuilder.com/"); print $snoopy->results; $submit_url = "http://lnk.ispi.net/texis/scripts/msearch/netsearch.html"; $submit_vars["q"] = "amiga"; $submit_vars["submit"] = "Search!"; $submit_vars["searchhost"] = "Altavista"; $snoopy->submit($submit_url,$submit_vars); print $snoopy->results; $snoopy->maxframes=5; $snoopy->fetch("http://www.ispi.net/"); echo "<PRE>\n"; echo htmlentities($snoopy->results[0]); echo htmlentities($snoopy->results[1]); echo htmlentities($snoopy->results[2]); echo "</PRE>\n"; $snoopy->fetchform("http://www.altavista.com"); print $snoopy->results;
0 0
- 采集(file_get_contents)
- 采集(file_get_contents)
- 采集(file_get_contents)
- file_get_contents采集加入库
- 数据采集之file_get_contents实现
- file_get_contents进行页面采集数据
- file_get_contents 无法采集 https 网站
- file_get_contents
- file_get_contents
- file_get_contents()
- 用file_get_contents 或 simplexml_load_file 采集的时候乱码
- 解决php无法通过file_get_contents或curl采集页面内容
- 解决php无法通过file_get_contents或curl采集页面内容
- php函数file_get_contents(一)
- php函数file_get_contents(一)
- file_get_contents模仿浏览器头(user_agent)获取
- file_get_contents的超时处理(膘叔)
- php获取网站内容(file_get_contents)
- 访问修饰符和多态
- POJ2502 Subway(最短路径)
- pdo的基本使用
- Android OCR 之 tesseract
- Android studio 中使用xUtils报错找不到org.apache.http.client.methods.HttpRequestBase的类文件
- 采集(file_get_contents)
- java集合框架01——总体框架一览
- LeetCode 143. Reorder List
- 网络:登录界面搭建与数据保存
- dp基础习题(4.13)
- ocr识别
- curl进行传值(post)
- Android手机上生成随机验证码(详细注释)
- java集合框架02——Collection架构与源码分析