采集(file_get_connect)

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <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>  
[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <?php  
  2. header("content-type:text/html;charset=utf-8");  
  3. $url="http://www.php7.com/dwzchd/aa.html";  
  4. $file=file_get_contents($url);  
  5. $pre='#<div class="mod-content clearfix show-content-bg">(.*)<div class="map-content clearfix">#isU';  
  6. preg_match($pre,$file,$content);  
  7. $pre1='#<a href="(.*)" .*">([^<>]*)</a>#isU';  
  8. preg_match_all($pre1,$content[0],$content1);  
  9. //print_r($content1);die;  
  10. $count=count($content1[0]);  
  11. //echo $count;die;  
  12. $pre2='#<img src="(.*)" width="16" height="16" class="img1">#isU';  
  13. preg_match_all($pre2,$content[0],$content2);  
  14. foreach($content2[1] as $key => $val){  
  15.     $content2[1][$key]= "http://www.php7.com/dwzchd/".$val;  
  16.     //echo $path['basename'];die;  
  17.     $img=file_get_contents($content2[1][$key]);  
  18.     file_put_contents("public/".$key.".png",$img);  
  19. }  
  20. //print_r($content2[1]);die;  
  21. echo "加载图片成功";  

下载图片

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. $count1=count($content2[1]);  
  2.             for($i=0;$i<$count1;$i++){  
  3.                 //$arr1[]['picture']=$content2[1][$i];  
  4.                 $img=file_get_contents($content2[1][$i]);  
  5.                 file_put_contents("public/".rand(1000,9999).'.png',$img);  
  6.             }  
snoopy,

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. include "Snoopy.class.php";  
  2.     $snoopy = new Snoopy;  
  3.       
  4.     $snoopy->fetchtext("http://www.php.net/");  
  5.     print $snoopy->results;  
  6.       
  7.     $snoopy->fetchlinks("http://www.phpbuilder.com/");  
  8.     print $snoopy->results;  
  9.       
  10.     $submit_url = "http://lnk.ispi.net/texis/scripts/msearch/netsearch.html";  
  11.       
  12.     $submit_vars["q"] = "amiga";  
  13.     $submit_vars["submit"] = "Search!";  
  14.     $submit_vars["searchhost"] = "Altavista";  
  15.           
  16.     $snoopy->submit($submit_url,$submit_vars);  
  17.     print $snoopy->results;  
  18.       
  19.     $snoopy->maxframes=5;  
  20.     $snoopy->fetch("http://www.ispi.net/");  
  21.     echo "<PRE>\n";  
  22.     echo htmlentities($snoopy->results[0]);  
  23.     echo htmlentities($snoopy->results[1]);  
  24.     echo htmlentities($snoopy->results[2]);  
  25.     echo "</PRE>\n";  
  26.   
  27.     $snoopy->fetchform("http://www.altavista.com");  
  28.     print $snoopy->results;  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值