采集(file_get_contents)
2016-07-05 19:53
253 查看
<span style="box-sizing: border-box; color: rgb(102, 102, 102); font-family: 'Microsoft YaHei'; font-size: 15px; line-height: 26px;"><span style="box-sizing: border-box; font-size: 16px;">用file_get_contents进行采集</span></span>
<?php header("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,
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;
相关文章推荐
- phpstorm配置xdebug进行远程调试(ubuntu)
- php && 逻辑与运算符使用说明
- MyBatis 学习总结---理论化知识点(一)
- Java基础 (第一天 helloword)
- 图解UML类图
- 威佐夫博弈
- php分页代码
- 移动开发----jsonObject和jsonArray
- ADB控制网络命令
- Lua学习笔记和遇到的问题
- 自定义控件View的属性 以及declare-styleable中format详解网址
- 【unix网络编程第三版】ubuntu端口占用问题
- PHP中获取当前页面的完整URL
- 【unix网络编程第三版】ubuntu端口占用问题
- UVALive 3971 组装电脑
- Leetcode 118. Pascal's Triangle
- Palindrome Pairs
- MQTT(使用mosquitto做broker)做Android推送部分总结
- C++中引用和指针的区别
- 获得json数据