03 2013 档案
摘要:在maoshou网站中得的模板的前提下,想在该网站上加一块广告部分,并且这一部分我们可以自行控制上下架在dede后台模板文件index中:<?php $content=file_get_contents("http://www.lexiangshow.com/****.php"); $content=iconv("GBK", "UTF-8//IGNORE", $content);//print_r($content); $guanggao_list=json_decode($content,true);//json解析后输出的数
阅读全文
摘要:新闻信息采集<?phpfunction canshujiequ($yuanma,$canshustr,$mubiao){ if($yuanma=='')return array(); if(strpos($canshustr,'[参数]')==false||strpos($mubiao,'[参数1]')==false) { echo '参数或组合字符串格式不对'; return array(); } $...
阅读全文
摘要:因为图片是相对路径,我们要把相对路径替换成绝对路径。<?php$contents=file_get_contents($url); $contents=str_replace("/EditManager/File/News/","http://news.ef360.com/EditManager/File/News/",iconv("GBK", "UTF-8//IGNORE", $contents));?>
阅读全文
摘要:图片的来源链接,以时间time()命名<?phpfunction GrabImage($url, $filename=""){ //$url 为空则返回 false; if($url == ""){return false;} $ext = strrchr($url, ".");//得到图片的扩展名 if($ext != ".gif" && $ext != ".jpg" && $ext != ".bmp"){echo "格式不支
阅读全文
摘要:现在总结有两个原因:1.编码问题。解决:<?php$url = "http://news.ef360.com/Articles/2013-3-8/299954.html"; $contents=file_get_contents($url); $contents=iconv("GBK", "UTF-8//IGNORE", $contents);echo $contents;?> 2.目标页面开了Gzip解决:@curl获取时<?phpfunction curl_get($url, $gzip=false){ $cur
阅读全文
摘要:1.图片文件上传,文件夹必须存在才能上传成功,可以再之前添加一个功能“判断文件夹是否存在,不存在时,就创建文件夹,存在则不作任何处理”<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-e
阅读全文
摘要:<?php $url = "http://maoshow.com/index.html"; $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); //在需要用户检测的网页里需要增加下面两行 //curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
阅读全文
摘要:echo iconv("UTF-8","GB2312//IGNORE",$guanggao_list[$i]["goods_name"]) ;忽视原来的编码问题,使用utf-8的编码格式
阅读全文
摘要:a. 如果欲使用gb2312编码,那么php要输出头:header(“Content-Type: text/html; charset=gb2312"),静态页面添加<meta http-equiv="Content-Type" content="text/html; charset=gb2312">,所有文件的编码格式为ANSI,可用记事本打开,另存为选择编码为ANSI,覆盖源文件。 b. 如果欲使用utf-8编码,那么php要输出头 :header(“Content-Type: text/html; charset=utf-8&
阅读全文
摘要:<?php$content=file_get_contents("http://www.ccl9.com//");$fo=fopen("ccl9.html","a");$fw=fwrite($fo,$content);fclose($fo);?>
阅读全文
摘要:写两个函数,使其支持中文:function arrayRecursive(&$array, $function, $apply_to_keys_also = false){foreach ($array as $key => $value) {if (is_array($value)) {arrayRecursive($array[$key], $function, $apply_to_keys_also);} else {$array[$key] = $function($value);}if ($apply_to_keys_also && is_string(
阅读全文
摘要:关键函数:json_decode(str,true)解析json json_encode(array()),转换成json实例如下:(带读写文件的例子)unlink("a.html");//删除原有文件 $fp=fopen("a.html","a"); $fw=fwrite($fp,json_encode($guanggao_list)); //将guanggao_list数组集成json后存入文件a.html fclose($fp); $fp=fopen("a.html","r"); $fw=
阅读全文

浙公网安备 33010602011771号