php 问问采集代码
代码如下 | 复制代码 |
<?php session_start(); header("content-type:text/html;charset=utf-8"); require("stole_config.php"); require("conn.php"); require("keyword.php"); if(!empty($_post['ask'])) { $ask=urlencode(trim($_post['ask']));//获取表单提交的问题 $sp="s".$ask; }else { $sp=urlencode($_get['sp']); } if(empty($_get['jl'])) { $_get['jl']=1; } $jl=$_get['jl']; $pg=intval($_get['pg']);//获取页数 $rs=intval($_get['rs']);//获得 记录的参数 if($rs>9) { $rs=0; $pg++; } if($pg>51) { echo "采集完毕! 总共采集 ".urldecode($sp)." ".$jl."条记录"; exit(); } if($sp)//有设定答案才开始 { $str=@file_get_contents("http://wenwen.soso.com/z/search.e?sp={$sp}&pg={$pg}"); @preg_match("/<ol class="result_list">(.*)</ol>/ius",$str,$asklist);//获取问答列表 //echo $asklist[1]; $url="/<a target="_blank" href="/z/(q.*.htm)/ius"; @preg_match_all($url,$asklist[1],$urllist);//获取 所有的问题 $t=$urllist[1][$rs]; $uid=$t; $suid="ww{$uid}"; $sct=mysql教程_query("select count(*) from {$table_prefix}c_article where suid='$suid' "); $sct=mysql_fetch_array($sct); $sct=$sct[0]; if($sct==0) { $html=@file_get_contents("http://wenwen.soso.com/z/${t}"); $html=str_replace("<pre>","",str_replace("</pre>","",$html)); $html=str_replace("<br/><br/><br/>","<br/><br/>",$html); //echo $html; @preg_match("/<div class="question_main">.*<h3>(.*)</h3>/ius",$html,$ask_title); $art_title=$ask_title[1]; @preg_match("/<div class="answer_con">(.*)</div>/ius",$html,$answer); $j=count($answer)-1; $art_content="";//商品详细 for($i=$j;$i>=1;$i--) { if(strlen($answer[$i])>$min_t1) { $art_content .= $answer[$i]; } } $art_content=trim($art_content); $s1="/(<a .*>)(.*)</a>/ius"; $art_content=preg_replace($s1,${2},trim($art_content)); $word_arr=explode(",",iconv("gbk","utf-8",$cj_word)); $word_allow=false;//初始化是否允许采集 $word_count=count($word_arr);//总数 for($i=0;$i<$word_count;$i++) { if(substr_count($art_title,$word_arr[$i])>0) { $word_allow=1; $i=$word_count; } } if($word_allow)//如果合法 { //开始处理数据库教程 if(strlen($art_content)>$min_t2) { echo "<font color=red>添加中............................</font><br>"; echo $art_title."<br>"; $art_title=iconv('utf-8','gbk', $art_title); $title_ct=mysql_query("select count(*) from {$table_prefix}c_article where art_title ='$art_title' ");//查看标题是否重复 $title_ct=@mysql_fetch_array($title_ct); $title_ct=$title_ct[0]; if($title_ct>0) { $art_title .="{$same_title}{$title_ct}"; } $art_content=iconv('utf-8','gbk',str_replace(" ","<br>",$art_content)); $art_content=strtr($art_content,$keyword); $art_time=date("y-m-d"); $sql="insert into {$table_prefix}c_article(art_title,art_content,art_time,art_author,suid) values('$art_title','$art_content','$art_time','$art_author','$suid')";//插入采集表 mysql_query($sql); if(empty($t_catx_id))//如果无分类 { $sql2="insert into {$t_table}({$t_art_title},{$t_art_content},{$t_art_time},{$t_artx_author}) values('$art_title','$art_content','$art_time','$art_author')"; }else { $sql2="insert into {$t_table}({$t_art_title},{$t_art_content},{$t_art_time},{$t_artx_author},{$t_catx_id}) values('$art_title','$art_content','$art_time','$art_author','$cat_id')"; } mysql_query($sql2);//插入文章表 $jl++;//如果存放数据库中 则记录加1 //处理数据库结束 }else { echo "长度不够"; } }else { echo "主题不符合要求"; } }else { echo "已经存在"; } $rs++; //记录下本次采集 的状况 $f_tt= urldecode($sp)."--页数".$pg." 记录数 ".$jl ; file_put_contents("ss.txt",$f_tt); echo "<script>location.href='wenwen.php?jl=".$jl."&sp=".$sp."&pg=".$pg."&rs=".$rs." ';</script>"; exit(); } ?> <link href="style.css教程" rel="stylesheet" type="text/css" /> <table width="700" border="0" align="center" cellspacing="1" bgcolor="#cccccc"> <tr> <td height="50" align="center" bgcolor="#00cc00"><h1><a href="http://www.111cn.net">荐礼啦</a>知道问问采集插件</h1></td> </tr> </table> <table width="700" border="0" align="center" cellspacing="1" bgcolor="#cccccc" style="margin-top:6px; margin-bottom:6px;"> <tr> <td height="30" align="center" bgcolor="#ffffff"><a href="cj_config.php">采集设置</a> <a href="uninstall.php" onclick="return confirm('您确定要卸载采集插件吗');">卸载采集</a> <a href="cj_view.php">查看采集记录</a> <a href="cj_help.php">采集帮助</a> <a href="baidu.php" target="_blank">知道采集</a> <a href="wenwen.php" target="_blank">问问采集</a></td> </tr> </table> <form action="wenwen.php" method="post"> <table width="628" height="49" border="0" align="center"> <tr> <td width="413" align="right"><input name="ask" type="text" id="ask" size="50"></td> <td width="205"><input type="submit" name="button" id="button" value="问问采集" style=" padding-left:15px; padding-right:15px; height:25px; line-height:25px;"></td> </tr> </table> </form> |
三种php删除文件代码
代码如下 | 复制代码 |
if($od=opendir($d)) //$d是目录名 去了解下这三个php函数:opendir() readdir() unlink() |
文件删除代码二 系统调用法
代码如下 | 复制代码 |
function del_dir($dir) { if(strtoupper(substr(php_os, 0, 3)) == 'win') { $str = "rmdir /s/q " . $dir; } else { $str = "rm -rf " . $dir; } } |
文件删除代码三
代码如下 | 复制代码 |
$info = "a123"; //目录名 if(is_dir($info)){ if(rmdir($info)){ echo "目录{$inof}删除完毕www.111cn.net"; }else{ echo "目录无法删除!原因--可能是目录下还存在文件!"; } } if(is_file($info)){ if(unlink($info)){ echo "文件{$info}删除完毕...!"; }else{ echo "文件{$info}mb.111cn.net删除失败...!尝试修改文件权限删除..."; if(chmod($info,0777)){ unlink($info); echo "文件{$info}权限修改后删除完毕..."; }else{ echo "文件{$info}无法通过web方式删除,可能是ftp权限对此文件有所设置..."; } } } |
最近发现很多网站转载本站文件,注请加上本站连接,谢谢合作!
一款实例的php图片加水印,切头像图和自动缩放代码,他可以把你上传的图片生成指定大小的效果图与可以对图片进行自动切剪,下面看实例。代码如下 | 复制代码 |
<html> http://code.google.com/p/queryphp/downloads/list frameworklibimg.class.php中的img类 <? */ class uploadrouter extends controller{
|
if(!isset($_session))session_start();
/**2010-6-22
* $data 数组类型 包含以下变量
-------------------------------
* $sub_type submit类型(upload:上传按钮 delete:删除按钮),默认upload
* $file 通过表单获取的$_files['filename']数组
* $img_tag_id 预览图片的<img>的id值
* $img_dir 上传图片的目录
* $max_file_size 单位m(兆),默认:1m
* $type_array 允许的上传的图片类型(默认:image/pjpeg、image/jpeg、image/gif)
**/
function upload($data){
if(!$data['file']){
echo '<script>alert("file不能为空!");</script>';exit;
}
if(!$data['img_tag_id']){
echo '<script>alert("预览图片标签id不能为空!");</script>';exit;
}
if(!$data['img_dir']){
echo '<script>alert("图片上传目录不能为空!");</script>';exit;
}
if(!isset($data['max_file_size'])){
$data['max_file_size'] = 1024 * 1024;
}else{
$data['max_file_size'] = $data['max_file_size'] * 1024 * 1024;
}
if(!isset($data['type_array'])){
$data['type_array'] = array('image/pjpeg', 'image/jpeg', 'image/gif');
}
if(!isset($data['sub_type'])){
$data['sub_type'] = 'upload';
}
$imgpath = '';
if(isset($data['sub_type']) && $data['sub_type'] == 'delete'){
if(isset($_session['name']) && $_session['name']){
if(is_file($_session['imgpath'])){
$b = unlink($_session['imgpath']);
}
unset($_session['name'], $_session['imgpath']);
if(!isset($_session['name'])){
echo '<script>alert("删除成功!");</script>';
echo '<script>parent.document.getelementbyid("'.$data['img_tag_id'].'").style.display = "none";</script>';
}else{
echo '<script>alert("删除失败!");</script>';
}
}else{
echo '<script>alert("没有稿件!");</script>';
}exit;
}
if(isset($_session['imgpath']) && $_session['imgpath']){
echo '<script>alert("稿件已经存在,要想重新上传请删除原来的稿件!");</script>';exit;
}
if(!in_array($data['file']['type'], $data['type_array'])){
echo '<script>alert("稿件类型不匹配,请上传.jpg、.gif和.png格式的图片!");</script>';exit;
}
if($data['file']['size'] > $data['max_file_size']){
echo '<script>alert("您上传的稿件过大,请选择2m以下的图片上传!");</script>';exit;
}
if(!is_dir($data['img_dir'])){
@mkdir($data['img_dir'], 0777, true);
}
$imgpath = $data['img_dir'].'/'.date('his', time()).rand(100, 999).$data['file']['name'];
$isupload = move_uploaded_file($data['file']['tmp_name'], $imgpath);
if(!$isupload){
echo '<script>alert("稿件上传失败,请尝试重新上传!");</script>';exit;
}else{
echo '<script>alert("稿件上传成功!");</script>';
}
$_session['name'] = $data['file']['name'];
$_session['imgpath'] = $imgpath;
return $imgpath;
}
/*test_start*/
$sub_type = '';
if(isset($_post['submit_upload']))$sub_type = 'upload';
if(isset($_post['submit_delete']))$sub_type = 'delete';
if($sub_type){//echo '<script>alert("'.$sub_type.'");</script>';exit;
$data = array( 'sub_type' => $sub_type,
'file' => $_files['file'],
'img_tag_id' => 'picview',
'img_dir' => 'upload_img',
);
$imgpath = upload($data);
}else{
$imgpath = isset($_session['imgpath'])? $_session['imgpath']: '';
}
?>
<form action="ad.php" method="post" enctype="multipart/form-data" target="frame">
<input type="file" name="file" class="input">
<input type="submit" name="submit_upload" value="上 传">
<input type="submit" name="submit_delete" value="删 除">
<iframe id="frame" name="frame" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank"></iframe>
</form>
<img id="picview" height="100" style="display:none;">
<script>
if("<?php echo $imgpath; ?>"){
parent.document.getelementbyid("picview").src = "<?php echo $imgpath; ?>";
parent.document.getelementbyid("picview").style.display = "block";
}
</script>
代码如下 | 复制代码 |
*/ //alipay.php代码 $url = $s22.$s14."?"; } pay.php页面 <?
$geturl = new alipay; <body> |
相关文章
- 这篇文章主要介绍了源码分析系列之json_encode()如何转化一个对象,对json_encode()感兴趣的同学,可以参考下...2021-04-22
- 有一种方法,可以不打开网站而直接查看到这个网站的源代码.. 这样可以有效地防止误入恶意网站... 在浏览器地址栏输入: view-source:http://...2016-09-20
- PHP去除html、css样式、js格式的方法很多,但发现,它们基本都有一个弊端:空格往往清除不了 经过不断的研究,最终找到了一个理想的去除html包括空格css样式、js 的PHP函数。...2013-08-02
- <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
- 本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
- 本文实例讲述了JS+CSS实现分类动态选择及移动功能效果代码。分享给大家供大家参考,具体如下:这是一个类似选项卡功能的选择插件,与普通的TAb区别是加入了动画效果,多用于商品类网站,用作商品分类功能,不过其它网站也可以用,...2015-10-21
- 本文实例讲述了JS实现自定义简单网页软键盘效果。分享给大家供大家参考,具体如下:这是一款自定义的简单点的网页软键盘,没有使用任何控件,仅是为了练习JavaScript编写水平,安全性方面没有过多考虑,有顾虑的可以不用,目的是学...2015-11-08
- php 取除连续空格与换行代码,这些我们都用到str_replace与正则函数 第一种: $content=str_replace("n","",$content); echo $content; 第二种: $content=preg_replac...2016-11-25
- php简单用户登陆程序代码 这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。 <center> <p> </p> <p> </p> <form name="form1...2016-11-25
- 公司一些wordpress网站由于下载的插件存在恶意代码,导致整个服务器所有网站PHP文件都存在恶意代码,就写了个简单的脚本清除。恶意代码示例...2015-10-23
- 本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
- 其实挺简单的就是if(navigator.userAgent.indexOf('UCBrowser') > -1) {alert("uc浏览器");}else{//不是uc浏览器执行的操作}如果想测试某个浏览器的特征可以通过如下方法获取JS获取浏览器信息 浏览器代码名称:navigator...2015-11-08
- index.php怎么打开?初学者可能不知道如何打开index.php,不会的同学可以参考一下本篇教程 打开编辑:右键->打开方式->经文本方式打开打开运行:首先你要有个支持运行PH...2017-07-06
- 一、日期减去天数等于第二个日期function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(a)alert(a.getFullYear() + "年" + (a.getMonth() +...2015-11-08
- 微信支付,即便交了保证金,你还是处理测试阶段,不能正式发布。必须到你通过程序测试提交订单、发货通知等数据到微信的系统中,才能申请发布。然后,因为在微信中是通过JS方式调用API,必须在微信后台设置支付授权目录,而且要到...2014-05-31
- 本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24
- 本文介绍了如何延迟javascript代码的加载,加快网页的访问速度。 当一个网站有很多js代码要加载,js代码放置的位置在一定程度上将会影像网页的加载速度,为了让我们的网页加载速度更快,本文总结了一下几个注意点...2013-10-13
- 小编分享了一段简单的php中文转拼音的实现代码,代码简单易懂,适合初学php的同学参考学习。 代码如下 复制代码 <?phpfunction Pinyin($_String...2017-07-06
PHP中func_get_args(),func_get_arg(),func_num_args()的区别
复制代码 代码如下:<?php function jb51(){ print_r(func_get_args()); echo "<br>"; echo func_get_arg(1); echo "<br>"; echo func_num_args(); } jb51("www","j...2013-10-04php导出csv格式数据并将数字转换成文本的思路以及代码分享
php导出csv格式数据实现:先定义一个字符串 存储内容,例如 $exportdata = '规则111,规则222,审222,规222,服2222,规则1,规则2,规则3,匹配字符,设置时间,有效期'."/n";然后对需要保存csv的数组进行foreach循环,例如复制代...2014-06-07